SOLVED

Dynamic Unique List - 2 Columns

Steel Contributor

Hello,

 

I can create a dynamic unique list with 1 column of data but what I need now is a dynamic unique list of data in 2 columns.  I have an example formula in the attached file but it only works on 1 column.  

 

Please see attached file.  

grateful for the help. 

Example (that is in the file)

Tony2021_0-1640464984630.png

 

8 Replies

@Tony2021 How about = UNIQUE(A2:B9) as shown in the picture below?

Screenshot 2021-12-26 at 07.28.51.png

Hello Riny, thats ingenious. I have a follow up though. In my "real" data set there are many columns between the columns I need for the array. How can I use 2 non contigous columns? Imagine that there is a column between columns A and B making the array to reference only column A and C. I tried to modify the array (with AND) but it didnt seem to work. I got a #value error. I hope that makes sense. Let me know if you have any questions.

best response confirmed by Tony2021 (Steel Contributor)
Solution

@Tony2021 Never tried that before but perhaps like in the attached file.

 

If this is not what you had in mind, I'd suggest you look into Power Query. Much more flexible and robust for these kind of tasks. At least in my humble opinion. 

nice! that works great. thank you so much. Happy Holidays.
Hi Riny, could you kindly direct me to the functionality in PQ be for something like this? I think I might explore it.

@Tony2021 The link below would be a good place to start.

https://exceloffthegrid.com/power-query-introduction/ 

The idea is to connect to the data, and do the necessary transformations, groupings etc. How exactly depends on the structure of the data. In your case I can imagine you select the columns you want to check. Merge them and then remove duplicates. But I might change my mind if I see the data. And, as always, there are probably many other ways to achieve something similar.

@Tony2021 

I rather liked @Riny_van_Eekelen 's idea of applying a FILTER horizontally to allow the columns to be selected dynamically.  If, on the other hand, the columns to be used are known ahead of time, the array to be filtered can be built using CHOOSE.  For example

= UNIQUE(
    CHOOSE({1,2,3}, 
      Table1[Column1],
      Table1[Column3],
      Table1[Column5]
    )
  )

Being a modern function UNIQUE works as well on arrays as it does ranges.  Using an Excel Table and ignoring the possibility of blanks. Riny's formula reduces to

= UNIQUE(
    FILTER(Table1,criterion)
  )

 

Wow. Peter that is amazing. I am learning new functions in excel. Thank you for the follow up. Both solutions work for me.
1 best response

Accepted Solutions
best response confirmed by Tony2021 (Steel Contributor)
Solution

@Tony2021 Never tried that before but perhaps like in the attached file.

 

If this is not what you had in mind, I'd suggest you look into Power Query. Much more flexible and robust for these kind of tasks. At least in my humble opinion. 

View solution in original post