Counting unique values

  • Thread starter Thread starter Dean
  • Start date Start date
D

Dean

I am trying to count the number of unique values in my data. Here is an
example:

589450
589451
589452
589453
589454
589455
589455
589455
589455

Ideally I want to know that the count for the first 5 values will be 1, but
also the count of 4 for the last four values, such as:

589450 1
589451 1
589452 1
589453 1
589454 1
589455 4


I have tried VLOOKUP, advanced filters, and COUNTIF, but I get the following
result:

589450 1
589451 1
589452 1
589453 1
589454 1
589455 4
589455 4
589455 4
589455 4

I have over 19,000 values that I need to count in this way so duplicates as
seen above in the last example are not desirable. Any help would be greatly
appreciated, and many thanks in advance for your help.
 
I put your data in column range A1:A9. Then put this formula in cell B1 and
copy down column b.

=IF(COUNTIF(A$1:A1,A1)=1,1,0)

Notice the dollar sign in front of the 1. The code counts the number of
times the data appears from the bottom of the table to the current row and
only puts a 1 in column B the first time the number in column A occurs. You
can then sum column b to get your unique values.
 
Back
Top