+ Reply to Thread
Results 1 to 22 of 22

Sorting data from a dynamic list

  1. #1
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Sorting data from a dynamic list

    Hi All,

    I'm doing a project for the company I work for, and I've hit a wall. I'm hoping someone on here could kindly help me please.

    I have a tab with a database on it which contains thousands of entries, I have 2 other tabs which refer to this database via vlookup. The first tab relates to the different routes, so I can type in a route number and all the stops for that route will show. I then have a column next to it where you type the stop numbers which are effected (the reason for this is that you will need to make 'notes' for multiple routes) and then a validation list giving 2 options, the notes then populate the second tab with the unique stop codes, which then gives you all the location information for each stop form the debase tab via vlookup.

    I hope this all makes sense so far.

    What I'd like to be able to do next, is dynamically sort the results into street names, ie if there are 2 stops effected on 'market street' then I'd like that to be reduced to 1 row looking something like this:

    [number of stops] [Road Name] [Stops effected]
    [2]. [market street]. [123, 456]
    [1] [high street] [1315]
    [3] [first avenue]. [489, 9876, 3571]

    Is this at all possible please

    Thank you
    Jeff

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2504 Win 11
    Posts
    24,709

    Re: Sorting data from a dynamic list

    Fast answers need visual help. Please read the yellow banner at the top of this page on how to attach a file and a mocked up solution.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    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
    48,238

    Re: Sorting data from a dynamic list

    Something like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    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


  4. #4
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    Hi all,

    Thanks for the quick replies. Here is a rough files of what I'd like to achieve, I've added what I hope the outcome to look like under the first table on 'sheet 1' for reference.

    Thanks Jeff
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    Quote Originally Posted by TMS View Post
    Something like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Thanks TMS for the reply, sadly this has gone over my head due to my basic knowledge lol. would you be able to kindly look at the attachment I've added or give me a rough explanation of what each of the functions does so that I can try to implement it in my sheet please. I'd like to expand my knowledge, but I can't make out where to start.

    thanks Jeff

  6. #6
    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
    48,238

    Re: Sorting data from a dynamic list

    I have had a look at the attachment but it's much more complex than I anticipated.

    I can get it to work, after a fashion, but it will need a bit of tweaking to match your expected results.

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

  7. #7
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Sorting data from a dynamic list

    Another option:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  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
    48,238

    Re: Sorting data from a dynamic list

    @josephteh: you're picking up, and repeating the route number, not the stop number.

    Have a look at my solution. Not better than yours, just different.

  9. #9
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Sorting data from a dynamic list

    Oh ya, thanks Trevor! Amended formula:
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    Hi TMS & Josephteh,

    Thank you both for doing this for me, it's pretty much what I wanted, the only thing I needed for it to do - is recognise that some stops with the same road name might have different closure types, ideally I'd like 1 line for everything with the same road name and same closure type to be on 1 line like it is on rows 28 & 29 of the example sheet. Is this at all possible or is this asking too much of excel.

    Could it be done in 2 tables and then merge them here. sorry I'm thinking as I write this, is it worth using a filter function to sort all of the closure types, like having 2 filters on the data tab, 1 for publicity only and the other for publicity and hoods. then have then merge for each of the same road name. Then collate the the results back into the 1 table on sheet 1.

    Sorry if that sounds long winded.

    I'm gonna start making the filters, if you guys have a better way, I'd appreciate it.

    thanks again

  11. #11
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    I've added the filters on the data tab.
    Attached Files Attached Files

  12. #12
    Forum Expert
    Join Date
    01-05-2013
    Location
    Singapore
    MS-Off Ver
    H&B2019
    Posts
    4,542

    Re: Sorting data from a dynamic list

    Your attached workbook is full of errors.

  13. #13
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    I know, the attachment rules said to reduce the stuff you have in the document and remove sensitive data. The full document is large - mostly because of the database, I've left the tabs which I need help with, once it's been figured out, I apply the formula's to the full document, those errors are happening because the tabs in which they reference have been deleted.

    thanks

  14. #14
    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
    48,238

    Re: Sorting data from a dynamic list

    Is this at all possible or is this asking too much of excel.
    I think it's possible. It's just more complex than the problem you initially described. It will, therefore, require further thought and effort . . . on top of the thought and effort put into addressing the original issue. Which is why you need to describe the real problem in the first place, not an over-simplified example.

    Just be patient, please. I'm sure someone will work something out for you. It's not that far out. But the unique element needs to be based on two columns, not one.

  15. #15
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    Hi TMS,

    Thanks for your reply. I'm sorry for wasting your time by me not explain this fully. When I did the original post - it made sense to me but obviously I'm aware of what I was after so therefore it would. I tried googling solutions but I was able to find the best way to describe what it was I wanted.

    I'm happy to be patient - is it worth looking at this as a step by step process rather than 1 complex formula which does this in one go.

    thanks Jeff

  16. #16
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,904

    Re: Sorting data from a dynamic list

    Perhaps this will help.
    1. Convert the range on the Stop List sheet into an Excel table (note that there are only six rows of data)
    2. Add two columns
    Stops Effected: =TEXTJOIN(", ",,IF(([ON STREET / ROAD]=[@[ON STREET / ROAD]])*([Closure Type]=[@[Closure Type]]),[STOP NUMBER],""))
    Number of Stops: =LEN([@[Stops Effected]])-LEN(SUBSTITUTE([@[Stops Effected]],",",""))+1
    3. In Power Query (aka Get & Transform) use the following code to produce the orange/white table on Sheet1:
    Please Login or Register  to view this content.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  17. #17
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    Hi JeteMc,

    Thank you very much for your reply, this has pretty much done what I needed. The only issue is I'm getting this error coming up and. I'm not sure how to fix it.
    Could you please let me know where I have gone wrong please.

    Thank you
    Attached Images Attached Images
    Attached Files Attached Files

  18. #18
    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. 2503 (Windows 11 Home 24H2 64-bit)
    Posts
    90,542

    Re: Sorting data from a dynamic list

    It tells you wnat the error is - there is no column with the name Cnt. Change Cnt wherever it appears in the code to whatever you have changed the column name to.
    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.

  19. #19
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    Hi All,

    Again, thank you all so much for taking your free time to help me.

    I've got the power query to work now. Is it possible to have this table update without having to run the query. My issue is that I will have to give this out as a template with people using it which have little to no experience in excel. If I need them to run this PQ in order for it to work, then I need to find another way.

    Thanks Jeff

  20. #20
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,904

    Re: Sorting data from a dynamic list

    If Power Query is the only concern then you might try this:
    1. Add a column (Not duplicate) to Table1 using:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    2. Produce an output table using the following formula:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Let us know if you have any questions.

  21. #21
    Registered User
    Join Date
    01-05-2025
    Location
    Watford
    MS-Off Ver
    365
    Posts
    10

    Re: Sorting data from a dynamic list

    This is perfect, thank you so much. Thank to all that took time to help me, it's greatly appreciated

  22. #22
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 365 version 2501
    Posts
    18,904

    Re: Sorting data from a dynamic list

    You're Welcome and thank you for the feedback. Please take a moment to mark the thread as 'Solved' using the thread tools menu above your first post. I hope that you have a blessed day.

+ 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. [SOLVED] Sorting Dynamic List based on a hierachy
    By kokjinq in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-09-2021, 09:39 AM
  2. Create dynamic drop down list from dynamic data source
    By rz6657 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-18-2016, 05:22 PM
  3. Sorting a Dynamic List of Data
    By andrewc in forum Excel General
    Replies: 6
    Last Post: 04-15-2014, 05:57 PM
  4. Sorting Data in Dynamic Ranges
    By andrewc in forum Excel General
    Replies: 2
    Last Post: 02-07-2014, 08:13 AM
  5. Sorting Dynamic Data
    By vt2009 in forum Excel General
    Replies: 1
    Last Post: 04-28-2012, 10:18 PM
  6. Multi Row Sorting & Create Header Row from Dynamic List
    By drew138 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-06-2009, 03:39 PM
  7. Dynamic List Sorting
    By icupat in forum Excel General
    Replies: 3
    Last Post: 06-02-2007, 09:33 AM

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