+ Reply to Thread
Results 1 to 36 of 36

Formula to get unique list of values from multiple columns in a table

  1. #1
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Formula to get unique list of values from multiple columns in a table

    Hi,

    I have a table of values that is like a basket of items, that I would like to produce of list of distinct items in the basket. I'm using Excel 365. I've tried using the UNIQUE function, but it works only on a single column, not the multiple columns I need to search.

    I'll add that every row in the first column has a value, many of the rows (up to 26 of them) in the following columns are empty, but all need to be considered. I don't know if this is relevant, but the 26 columns are derived by extracting values from a comma-delimited text, so I have all the values per row in a single column source row.

    Any suggestions are much appreciated. TIA. Paul

    I've added an excerpt to demonstrate the source data and what I'm looking for.
    Attached Files Attached Files
    Last edited by paulma1960; 10-13-2021 at 02:27 PM. Reason: Clarity

  2. #2
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,781

    Re: Formula to get unique list of values from multiple columns in a table

    Post a small Excel sheet (not a picture) showing realistic & representative sample data WITHOUT confidential information (10-20 rows, not thousands...) and some manually calculated results. For a new thread (1st post), scroll to Manage Attachments, otherwise scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.

  3. #3
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    Thanks CARACALLA, though I'm confused, as I've posted an Excel workbook, not a pic. P

  4. #4
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,416

    Re: Formula to get unique list of values from multiple columns in a table

    Cell B11 formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by wk9128; 10-14-2021 at 03:25 AM.

  5. #5
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    That's brilliant, wk9128. I just had to wrap that formula in the UNIQUE and SORT functions to get exactly what I needed. That makes it look so easy-peasy! Many thanks.

  6. #6
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,416

    Re: Formula to get unique list of values from multiple columns in a table

    @paulma1960 You're Welcome. Glad to help . Thank You for the feedback


    If you finally get a solution please mark your thread as SOLVED:
    - Click Thread Tools above your first post, select "Mark your thread as Solved".
    - Please click on the *Add Reputation button at the bottom left. you can thank those who have helped

  7. #7
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    wk9128 I'm looking for a further refinement, if possible. As you can see in the file I posted, the table is derived from a comma-delimited list (CDL). Is there a similar method of extracting the list direct from the CDL, without the need of the table? This would be most useful, as my spreadsheet is very complex and these tables take up about 90% of the columns. Cheers, Paul

  8. #8
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    How about
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    although there are values in A2A6 that do not exist in your table

  9. #9
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,416

    Re: Formula to get unique list of values from multiple columns in a table

    @paulma1960 late reply , @Fluff13 did a great job . Thanks

  10. #10
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    Sorry for the late reply, I've been busy with work and only tried it now. Fluff13, that solution was also brilliant. I've not used FILTERXML function before, and I take it I would need to know XML to use it effectively???

    I'm hoping for a further refinement. Is it possible to conditionally extract values from the table? All the values in the table are in a master list, with other attributes in contiguous columns (see attached file). I'd like to know if I can extract just the values in the original table that meet a certain criteria, such as a selected colour, and/or date. Any suggestions much appreciated....

    PS I should mention, each item has a date, and I'm trying to find the items that are running late. So the dates in the column S need to be compared with another date, which could be put in column U, or vice versa.
    Attached Files Attached Files
    Last edited by paulma1960; 10-19-2021 at 11:28 AM.

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

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


    I take it I would need to know XML to use it effectively
    Not really, I know nothing about XML codeing

  12. #12
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    Quote Originally Posted by Fluff13 View Post
    Not really, I know nothing about XML codeing
    What's a good resource for learning more? These formulas are very, very useful.

    Your formula above is also excellent, for me, in terms of selecting a colour. How about a date test? Each item has a date that needs to be checked against another date (and each item's date is unfixed, ie, not tied to other items' dates)?

  13. #13
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    What's a good resource for learning more?
    Ufortunately I don't know of any resources relating to the Filterxml function.

    I'm afraid I have no idea what you mean by
    Each item has a date that needs to be checked against another date (and each item's date is unfixed, ie, not tied to other items' dates)?

  14. #14
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    In the file I uploaded, col U, there's an expected date, and the actual date that I need to compare with. Imagine, if you will, in col V with other dates, and each date in col U needs to be compared with the date in col V.

  15. #15
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    There are no dates in col V

  16. #16
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    I know that, that's why I suggested, 'imagine, if you will' that there are...

  17. #17
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    Ok, you can put a date in V11 & use
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    Thanks, Fluff13, but that's not working for me, and I'm getting a #CALC! error (in cell Z11).
    Last edited by paulma1960; 10-22-2021 at 11:27 AM.

  19. #19
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    Thanks, Fluff13, but that's not working for me, and I'm getting a #CALC! error (in cell Z11). I want to select only the items (of a given colour) that are late, by comparing dates (the Status column is just a visual aid for testing, but not available in my live sheet).

    Also, with the previous iteration of the problem (Filtering by 'Yellow'), it works for Yellow and other colours, but not Blue or Green. I'm using drop-down selection, but I get the same result if I hard-code the colour. I get a CALC error. Can you suggest what I'm doing wrong? TIA. Paul
    Attached Files Attached Files
    Last edited by paulma1960; 10-22-2021 at 11:30 AM. Reason: Clarity

  20. #20
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    The formula in W11 works for me, I see
    Excel 2016 (Windows) 32 bit
    W
    10
    Conditional
    11
    AB_01
    12
    AB_21
    13
    AB_8.20
    14
    AB_8.21
    15
    AB_8.28
    Sheet: Sheet1

    And if I change the formula to look at W8 instead of hard coding the colour it still works

  21. #21
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    I'm not following your cell references. The filter-by-colour formula is in cell Y11. It works for me, both with drop-down selection and hard-coded selection for all the colours except when I select Blue or Green. This seems very weird to me.

    The formula in cell Z11, for filtering by late date isn't working at all...

  22. #22
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    With the workbook from post#19, there are no formulae in Y11 or Z11, just W11.

    The reason you get a #calc error for blue & green, is that there are no matches for those colours.

  23. #23
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    OK, that was weird. Somehow I posted the wrong workbook, so much confusion all round, it seems. I've renamed it (#3). The formulas I'm having problems with are in cells Y11 and Z11.
    Attached Files Attached Files

  24. #24
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    Ok, you cannot do that with countifs, try it like
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    although in that data there are no cells where U is less then Y

  25. #25
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,823

    Re: Formula to get unique list of values from multiple columns in a table

    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.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  26. #26
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    That's excellent, thanks Fluff13. It'll take me a while to understand what's going on, but I had no problems implementing your solution. I'm attaching the sample file, formula is in cell V11, for anyone who might want to take advantage. Cheers...
    Attached Files Attached Files

  27. #27
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    Glad to help & thanks for the feedback.

  28. #28
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    Fluff13, I can't get my data to work for me, with what you've suggested. My data is very complex, and I think I over-simplified it in the workbook I uploaded. In the workbook I'm uploading now, I'm looking for milestones that are running late. The milestones are in H4:J8, and their dates (if available) are in cells K4:M8. I'm not interested in milestones that don't have a corresponding date, and I'm looking for the list of milestones whose expected date is later than the planned date (which are in red).

    In cell H12, I've extracted the milestones in the milestone bucket, and in cell K12 I've extracted the dates from the date bucket. So, I want to interrogate the date bucket and capture only those dates running late, with the milestones that are late. The desired list you can see at cell N12. The table in columns B:C can be ignored, they're relevant only in that the milestones in col E need their dates.
    Attached Files Attached Files

  29. #29
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

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

  30. #30
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    That works great, thanks Fluff13, and it works fine in my sample workbook, but not with my live data. There's an error in the logic.

    The expected dates need to be compared, not with their planned dates in column C, but with the planned date of the milestone they're dependent on, in column F.

    For example, the expected date of MS_4 in cell M4 needs to be tested against the due date of MS_1 in cell F4, and not the due date of MS_4 in cell C7. The issue is that a dependent milestone might not be running late, but it's expected date might cause another milestone to run late. So, if in cell C7, the planned date for IM_4 was 24-Dec-22, it would still be red, because that date is after the planned date for MS_1, 24-Oct-22.

    Also, I needed to put an empty string as the 4th argument in the XLOOKUP, for when a value couldn't be found.
    Last edited by paulma1960; 10-26-2021 at 04:46 AM.

  31. #31
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,823

    Re: Formula to get unique list of values from multiple columns in a table

    1. Please remove the SOLVED tag if you require further assistance on this.
    2. Provide a more realistic sample dataset that properly reflects the real set-up.

  32. #32
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

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

  33. #33
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    That's great, Fluff13. I had to adjust your formula as the FILTER wasn't required at all, making it simpler. I just have to use OFFSET to another dynamic range so that the formula is fully dynamic and not based on a hard-coded cell reference, for now the following works for me. Thanks so much, I'm learning a lot from this.

    Please Login or Register  to view this content.
    Last edited by paulma1960; 10-26-2021 at 02:03 PM.

  34. #34
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,079

    Re: Formula to get unique list of values from multiple columns in a table

    Glad it's sorted & thanks for the feedback.

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

    Re: Formula to get unique list of values from multiple columns in a table

    Please try

    =LET(x,FILTERXML("<x><m>"&TEXTJOIN("</m><m>",,REPT(H4:J8&" "&K4:M8,K4:M8>F4#))&"</m></x>","//m"),m,MID(x,{1,6},{5,6}),IFERROR(--m,m))
    for fixed length of MS_xx

    or vary length

    =LET(x,FILTERXML("<x><m>"&TEXTJOIN("</m><m>",,REPT(H4:J8&" "&K4:M8,K4:M8>F4#))&"</m></x>","//m"),m,TRIM(MID(SUBSTITUTE(x," ",REPT(" ",20)),{1,21},20)),IFERROR(--m,m))
    Attached Files Attached Files

  36. #36
    Forum Contributor
    Join Date
    08-31-2021
    Location
    Kassel, Germany
    MS-Off Ver
    365 v2308
    Posts
    187

    Re: Formula to get unique list of values from multiple columns in a table

    Thanks, Bo_Ry, that seems to be a suitable alternative solution to my original problem, though I've moved on to other issues at present. I'll revisit it with your suggestion when I can. Cheers...

+ 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] Create a list of unique values from several columns in a dynamic table.
    By schurchill39 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-28-2018, 06:51 PM
  2. [SOLVED] Creating unique list of values from multiple columns not in sequence.
    By Big.Moe in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-09-2017, 04:47 AM
  3. Replies: 5
    Last Post: 09-04-2016, 07:09 AM
  4. [SOLVED] List unique values from multiple columns
    By macrorookie in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-29-2016, 07:56 PM
  5. [SOLVED] Combining list of Unique Values from Multiple Columns and with Total Value
    By masood78 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 07-11-2016, 07:27 PM
  6. Replies: 2
    Last Post: 06-16-2016, 08:09 PM
  7. List of Unique Values from Multiple Columns
    By filkod in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 03-06-2015, 03:57 AM

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