+ Reply to Thread
Results 1 to 15 of 15

Sort column based on multiple values in another column

  1. #1
    Registered User
    Join Date
    12-25-2018
    Location
    Bosnia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Sort column based on multiple values in another column

    I have large data set that I need to filter. I need to identify all the cells in column A that have multiple occurrences in column A with different values in column B, while ignoring the ones who have only one or few values in B.

    When using simple filter I have to manually filter each value in A and determine if it is reoccurring with multiple values in B. Since it is huge amount of data, that is time consuming. I can not use conditional filtering either since the values in B are not defined set and can not be used as condition.

    In example that I have uploaded, only cells with values 101 and 103 are interesting since they have multiple values in column B, while cells with values 102 and 104 should be ignored since they have only one value in column B (even if the same value is reoccurring multiple times):

    Sort column based on multiple values in another column - example.jpg

    I would appreciate any help or assistance in solving this task.

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Sort column based on multiple values in another column

    Please try at D2 copy across all table

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

  3. #3
    Registered User
    Join Date
    12-25-2018
    Location
    Bosnia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Sort column based on multiple values in another column

    Hi Bo_Ry, thanks for looking at this and spending your time.

    I've tried your formula, but got errors from excel. It seems that it needed to replace comma with semicolon in formula in order for excel to accept it so did it like this:

    =IFERROR(INDEX($A:$B;AGGREGATE(15,6;ROW($A$2:$A$99)/($A$2:$A$99=100+INT((COLUMNS($D2:D2)+2)/3));ROWS(D$2:D2));MOD(COLUMNS($D2:D2);3));"")

    No more error, but no result either, only blank cells. I placed the formula in D2 and dragad it down, but no results, just empty cells.

    Can you please check it one more time, maybe test it?

    Thanks

  4. #4
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Sort column based on multiple values in another column

    Please upload your file.
    Go Advanced -> Manage Attachments -> Upload

  5. #5
    Registered User
    Join Date
    12-25-2018
    Location
    Bosnia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Sort column based on multiple values in another column

    Here is the file:
    Attached Files Attached Files

  6. #6
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Sort column based on multiple values in another column

    Why are you using .xls which is almost 15 years out of date, when you have a 2016 version of Excel??

    Kill the merged cells in g1, J1, etc. Then, In D3:
    =IFERROR(INDEX($A:$A,AGGREGATE(15,6,ROW($A$3:$A$100)/($A$3:$A$100=E$1),ROWS(D$3:D3))),"")

    In E3:
    =IFERROR(INDEX($B:$B,AGGREGATE(15,6,ROW($A$3:$A$100)/($A$3:$A$100=E$1),ROWS(E$3:E3))),"")

    REPLACE , with ;

    Select both cells and drag downtoD15/E15. Copy paste into G4, J4, etc.
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  7. #7
    Registered User
    Join Date
    12-25-2018
    Location
    Bosnia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Sort column based on multiple values in another column

    Thanks Glen, this works on the file I uploaded and you made a great solution for it.

    But I probably was not clear enough, sorry. In my real set, there are thousends of values in A so I can not have separete results/column for each single A value

    The columns from D to N in my uploaded test file were only to show how sorting should work, what would be relevant result, ant what would not be relevant.

    The point is, I have only A and B columns with huge value sets and I need to identify A values that have multiple different values in B. Do you have any idea how to achieve that? Maybe to sort the whole A column so that top positions contain A cells that have the most different occurances is B and therefore to have most "interesting" values on top and it is easy to go through it?

    Thanks again

  8. #8
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Sort column based on multiple values in another column

    Please try D3 copy across all table

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

  9. #9
    Registered User
    Join Date
    12-25-2018
    Location
    Bosnia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Sort column based on multiple values in another column

    Thanks Bo_Ry, it works now on test file. Great job.

    But as I said to Glenn:

    "I probably was not clear enough, sorry. In my real set, there are thousends of values in A so I can not have separete results/column for each single A value

    The columns from D to N in my uploaded test file were only to show how sorting should work, what would be relevant result, ant what would not be relevant.

    The point is, I have only A and B columns with huge value sets and I need to identify A values that have multiple different values in B. Do you have any idea how to achieve that? Maybe to sort the whole A column so that top positions contain A cells that have the most different occurances is B and therefore to have most "interesting" values on top and it is easy to go through it?"

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Sort column based on multiple values in another column

    ??? In c3:

    =COUNTIFS(A:A,A3,B:B,B3)

    and filter by whatever combination you wish. I saved the file as a modern .xlsx. You didn't actually answer my Q about why you are using an outdated file type.
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    12-25-2018
    Location
    Bosnia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Sort column based on multiple values in another column

    Dear Glenn,

    regarding xls format, well it is a habit from the old days when xlsx or docx were new and older versions of excel (2003) were uncompatible with new format. In bigger organisations there are still some Office 2003 versions, but more importanly a lot of people use LibreOffice or similair. Libre will open new format but it is not 100% compatible. So when I use basic functions of document I tend to save it in old format. The one I uploaded was suposed to be in xlsx I hope it is more clear now

    About your solution, as I can see it only counts how many times certain value in B reocured. It is elegant sulution but it is not what was intended.

    Let me try to be more helpful. I will upload new file with list of passengers in A column and stations in B column. Solution is required to find out which passenger traveled the most. It is not relevant if a passenger apeared several times in only one station. I would need only the passengers that had traveled, changed several stations (even if they had multiple stops in same station - as long as they had traveled to other as well).

    Thanks
    Attached Files Attached Files

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Sort column based on multiple values in another column

    What is the expected answer for Passenger 1?

  13. #13
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: Sort column based on multiple values in another column

    Maybe this ???
    Attached Files Attached Files

  14. #14
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Sort column based on multiple values in another column

    Maybe

    D1 copy to the right
    Formula: copy to clipboard
    Please Login or Register  to view this content.



    D2 copy to the right and down
    =IFERROR(INDEX($B:$B,AGGREGATE(15,6,ROW($A$2:$A$101)/($A$2:$A$101=D$1),ROWS(D$2:D2))),"")
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    12-25-2018
    Location
    Bosnia
    MS-Off Ver
    Professional Plus 2016
    Posts
    7

    Re: Sort column based on multiple values in another column

    Answer for passenger 1 is:
    5
    35
    2
    2
    69

    Most apropriate solution is to somehow derive, identify ALL the persons who have traveled (changed at least two stations), sorted by person who have travelled the most, down to the persons who didnt move from single station. Maybe in new columns? It is neccessary to identify all moving passengers, in order to analyze every single one for sales oportunities for instance. Since the real data set can have tens of thousends values, it is neccessary to automate identification of the ones who moved.

+ 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. Macro to sort column based on the values
    By chrisellis250 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2016, 11:57 AM
  2. Sort Different sections based on values in a column
    By thelegazy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-26-2013, 02:28 AM
  3. [SOLVED] Counting Multiple Values in a column based on critera in seperate column
    By ERoberts in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-11-2013, 01:08 PM
  4. [SOLVED] sort and delete based on the values in column c and column j?
    By barbibchn in forum Excel General
    Replies: 1
    Last Post: 01-14-2013, 04:25 PM
  5. Sort one column based on values in another column?
    By mogabi in forum Excel General
    Replies: 2
    Last Post: 01-17-2011, 01:26 AM
  6. How do I sort based upon values in another column?
    By Huuuze in forum Excel General
    Replies: 5
    Last Post: 10-27-2010, 10:54 AM
  7. [SOLVED] Sort column with multiple values
    By gildedlily in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 05-26-2006, 04:55 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