How to get unique values in a column using excel formula

我的未来我决定 提交于 2019-12-03 10:02:50

You can use the remove duplicate function

Select the column range

Go to Data Tab

then click on Remove Duplicates

Here is a solution to get a list of unique items from your tables

There is two parts to this solution.

Part 1) Unique Count

{=SUM(IF(FREQUENCY(IF($A$2:$A$10<>"",MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1),1))}

This will count the number of unique items in your data table and will ignore any blanks

*Note this is an array formula and you will need to use "Ctrl" + "Shift" + "Enter" to use

Part 2) Unique List

This formula will give you the list of unique items in your table

={IF(ROWS($E$5:E5)>$E$2,"",INDEX($A$2:$A$10,SMALL(IF(FREQUENCY(IF($A$2:$A$10<>"",MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1),ROW($A$2:$A$10)-ROW($A$2)+1),ROWS($E$5:E5))))}

again this is an array formula. You can then drag this formula down to get all the unique items.

This formula is a dynamic formula, meaning you can set the data range past your current data range and the list will update as you enter new values.

*Here is a great video to watch to understand this further

https://www.youtube.com/watch?v=3u8VHTvSNE4

I think I've found a more elegant workaround without array-functions or built-in functions:

  • 1st column (ID):
    this is the array from we'd like to select distinct values

  • 2nd column (criteria): checks whether this is the first occurrence
    =IF((ROW()-1)=MATCH(A2,$A$2:$A$500,0),1,0)

  • 3rd column (cumulative):
    =SUM($B$2:B2)

  • 4th column (count):
    this is constant 1

  • 5th column (unique ID):
    =OFFSET($A$2,MATCH(ROW()-1,$C$2:$C$501,0)-1,)

  • 6th column (count):
    =SUMIF(A2:A21,F2,D2:D21)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!