Count the number of unique values

BrutalLogiC

Active Member
Joined
Feb 26, 2006
Messages
274
Office Version
  1. 365
Platform
  1. Windows
hello can you help me please

how do I count the number of unique numbers or texts in a column

A1 = 2
A2 = 3
A3 = 4
A4 = blue
A5 = 3
A6 = blue

the formula should count 4 in column A since there are 4 unique values

hope that makese sense

thanks
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
hello can you help me please

how do I count the number of unique numbers or texts in a column

A1 = 2
A2 = 3
A3 = 4
A4 = blue
A5 = 3
A6 = blue

the formula should count 4 in column A since there are 4 unique values

hope that makese sense

thanks
This one will ignore empty/blank cells...

=SUMPRODUCT((A1:A10<>"")/COUNTIF(A1:A10,A1:A10&""))
 
Upvote 0
thanks! I do want it to ignore the blanks

what about if I filter column B?

so in column B I had
B1 = yes
B2 = yes
B3 = no
B4 = yes
B5 = yes
B6 = yes

and I filtered by yes, i would want the answer to update from 4 unique (when unfiltered) to 3 unique when filtered by column B = yes

hope I am explaining myself!
 
Upvote 0
thanks! I do want it to ignore the blanks

what about if I filter column B?

so in column B I had
B1 = yes
B2 = yes
B3 = no
B4 = yes
B5 = yes
B6 = yes

and I filtered by yes, i would want the answer to update from 4 unique (when unfiltered) to 3 unique when filtered by column B = yes

hope I am explaining myself!
Ok, let's assume the full unfiltered range is A3:B10.

Array entered**:

=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(A3:A10,ROW(A3:A10)-ROW(A3),0,1)),MATCH(A3:A10,A3:A10,0)),ROW(A3:A10)-ROW(A3)+1)>0,1))

** array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.
 
Upvote 0
thanks! I do want it to ignore the blanks
Control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF($A$1:$A$6<>"",MATCH("~"&$A$1:$A$6,$A$1:$A$6&"",0)),
ROW($A$1:$A$6)-ROW($A$1)+1),1))

what about if I filter column B?

so in column B I had
B1 = yes
B2 = yes
B3 = no
B4 = yes
B5 = yes
B6 = yes

and I filtered by yes, i would want the answer to update from 4 unique (when unfiltered) to 3 unique when filtered by column B = yes

hope I am explaining myself!

Control+shift+enter, not just enter:
Rich (BB code):
=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(A1,ROW(A1:A6)-ROW(A1),,1)),
   IF(A1:A6<>"",MATCH("~"&A1:A6,A1:A6&"",0))),ROW(A1:A6)-ROW(A1)+1),1))

By the way, here is a link on performance issues regarding formulas for unique count:

http://www.mrexcel.com/forum/showthread.php?t=292473
 
Last edited:
Upvote 0
Thanks again, my range is D4:D500 and I've got

{=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(D4:D500,ROW(D4:D500)-ROW(D4),0,1)),MATCH(D4:D500,D4:D500,0)),ROW(D4:D500)-ROW(D4)+1)>0,1))}

seems very complicated but it works fine cheers!
 
Upvote 0
Thanks again, my range is D4:D500 and I've got

{=SUM(IF(FREQUENCY(IF(SUBTOTAL(3,OFFSET(D4:D500,ROW(D4:D500)-ROW(D4),0,1)),MATCH(D4:D500,D4:D500,0)),ROW(D4:D500)-ROW(D4)+1)>0,1))}

seems very complicated but it works fine cheers!
Yes, it is very complicated.

For the life of me, I don't know why Miscosoft doesn't come up with more functions for dealing with filtered data. :mad:

Thanks for the feedback! :cool:
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top