+ Reply to Thread
Results 1 to 14 of 14

Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

  1. #1
    Registered User
    Join Date
    04-08-2024
    Location
    London, England
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    8

    Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Hi All!

    I am trying to sort 77,000+ lines of alphanumeric data. Ideally I don't want to split text to columns and filter on separate pieces as there is far too much data and the string is of varying lengths (I've so far only done this on the letter and still a large portion is out of sequence).

    There are multiple variations of the alphanumeric data and i would first like it to order by the middle letter 'a','b','c','dthen by the first string of numbers, then by the other string of number, and then finally the numbers on the end.

    [second element (number string with/without colon ( separating the numbers - it is still one string of varying length)].[first element (one character letter).[third element (number of character length 2-3)].[fourth element (number of characters 1-4)]

    The primary issue is there is a lot of decimalisation, varying punctuation, no fixed lengths which makes this a nightmare!

    I can also access the raw data in SQL so i have the ability to Regex there too! e.g. evaluate('REGEXP_INSTR(%1, ''^[0-9].*A+$'')',"TABLE"."COLUMN")


    example of the order i would like :
    18.a.89.1
    18:27.a.90.1
    18:3.a.90.1
    18:3.a.90.1a
    18:3.a.90.11a
    18:3.a.90.22
    18:3.a.90.22a
    18:3.a.90.23
    67:7.a.90.5
    69:01.a.1.1-
    70:1.a.85.1
    70:1.a.85.1-4
    70:1.a.85.12-
    100:01.b.7.53
    10:1.b.90.1
    10:1.b.95.1
    10:1.b.95.2
    10:1.b.95.3
    10:2.b.95.1
    10:2.b.95.2
    58:5.b.201.1
    58:5.b.95.1-2
    58:5.b.95.6
    59:1.b.200.1
    69:01.b.36.55
    2:55.c.95.422
    2:55.c.95.423
    2:55.c.95.424
    44:5.c.201.16
    44:5.c.201.5
    44:5.c.90.22
    60:1.c.200.14
    60:1.c.200.2
    60:1.c.202.2
    1:8.d.95.2
    1:8.d.95.3
    1:8.d.95.4
    61:29.d.90.1
    Attached Files Attached Files
    Last edited by potofteatohavein; 04-10-2024 at 05:39 AM.

  2. #2
    Registered User
    Join Date
    06-29-2022
    Location
    South Australia
    MS-Off Ver
    MS Windows 365 - Version 2204
    Posts
    46

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Please Login or Register  to view this content.
    Last edited by AliGW; 04-10-2024 at 09:12 AM. Reason: Code tags added - please review the forum guidelines.

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    There are multiple variations of the alphanumeric data and i would first like it to order by the middle letter 'a','b','c','dthen by the first string of numbers, then by the other string of number, and then finally the numbers on the end.
    But the example is not so .
    c(Row 6) is coming after a(Row 5), then once again a(row 7) is coming
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  4. #4
    Registered User
    Join Date
    04-08-2024
    Location
    London, England
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    8

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Apologies, my mistake. I can't quite get the above to work so still looking for a solution. I think it might be an issue of my lack of expertise.

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Try In R4
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    04-08-2024
    Location
    London, England
    MS-Off Ver
    Office LTSC Professional Plus 2021
    Posts
    8

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Okay so just to confirm in regards to editing the formula; what value needs to go into [Number]? having tried the cell value G4 I then get #NAME?

    Please forgive my lack of Excel experience

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,750

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    @KV

    There are functions in that formula that don't exist in Excel 2021 (e.g TEXTBEFORE). You yourself have 2019 in your profile - if you're using 365, then it needs updating.

    @potofteatohavein

    The formula in post #5 will not work in Office 2021.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,621

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    @kv: Excel 2021 doesn't have the TEXTxxxxxx functions or HSTACK or SORTBY. I don't think 2019 does either.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,750

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Actually, 2021 DOES have TEXTJOIN, which first appeared in 2019, but it does not have the other three. It certainly doesn't have HSTACK (365), but it does have SORTBY (2021).

    For anyone who's still getting caught out, bookmark this site: https://bettersolutions.com/excel/fu...-functions.htm

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,621

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    So, if it's in 2019, it's also in 2021?

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,750

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Yes - correct.

  12. #12
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    @AliGW
    I have already told that I am having 2019. With the help of internet I am using 365 functions.

    Regarding other functions that are not in 2021 I am not aware of it.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2509 (Windows 11 Home 24H2 64-bit)
    Posts
    92,750

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    I have shared this link above: https://bettersolutions.com/excel/fu...-functions.htm

    Bookmark it and refer to it in future, please.

    There is no point in offering a 365 solution to someone with Excel 2021 - it simply won't work.

  14. #14
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,710

    Re: Alphanumeric sorting (4 elements) of 77,000+ lines! SQL option too.

    Thanks for the suggestion and link. If somebody having same problem and having version 365 it may help him in future.
    Here is the VBA solution for 2021 and other versions.
    Assuming BA:BE columns are free, they are used as helper columns during running macro. If they are not free columns are to be changed.
    Result is in Column R.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kvsrinivasamurthy; 04-11-2024 at 10:13 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Alphanumeric sorting
    By chisinau in forum Excel General
    Replies: 1
    Last Post: 01-22-2022, 11:03 AM
  2. Alphanumeric sorting
    By panagle in forum Excel General
    Replies: 1
    Last Post: 04-17-2014, 12:05 AM
  3. Data elements within a single cell need to be on individual lines
    By d1jpd01 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-01-2013, 08:10 AM
  4. Excel 2007 : Alphanumeric Sorting
    By melhalp in forum Excel General
    Replies: 4
    Last Post: 03-01-2010, 07:16 AM
  5. Sorting row with a alphanumeric value.
    By patwary8 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-07-2008, 04:10 PM
  6. [SOLVED] alphanumeric sorting
    By Dhinakaran in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-15-2006, 03:30 PM
  7. Bart chart with lines showing % change between elements
    By Tom in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-30-2005, 09:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1