7 Amazing Ways to Count Unique Values in Excel

80+ Excel Keyboard Shortcuts ➜

✍️ Written by Puneet Gogia (Microsoft MVP)

Easiest Way to Count Unique values in Excel

The easiest and newest way to count unique values in Excel is to use the unique function, which is a new dynamic array function. Then, once you can use the count function, you get an instant count of the unique values.

fx Formula
=COUNTA(UNIQUE(H5:H14, FALSE, TRUE))
  

This is a new function which only available in Excel 365

How COUNTA(UNIQUE(...)) counts distinct values The range H5:H14 has ten values with repeats. UNIQUE keeps one of each, leaving five distinct values. COUNTA counts them and returns 5. Range H5:H14 UNIQUE result Apple Banana Apple Cherry Date Banana Apple Date Fig Cherry UNIQUE keeps one of each Apple Banana Cherry Date Fig COUNTA counts them 5values counted kept — appears in result duplicate — dropped by UNIQUE

The formula counts how many values appear only once. It pulls out only the values that show up a single time and throws away anything that repeats.

The UNIQUE, with that final FALSE, returns one copy of each value, keeping a single instance of repeated items instead of dropping them. COUNTA then counts that list.

Count Unique Values in Any Excel Version 

If you don’t have the UNIQUE function in your Excel version, you can use a specific formula with the SUMPRODUCT and COUNTIF functions. This formula is also smart and powerful enough to return the count of unique values.

fx Formula
=SUMPRODUCT(1/COUNTIF(H5:H14, H5:H14))
  
How SUMPRODUCT(1/COUNTIF(...)) counts distinct names COUNTIF gives each name's occurrence count. 1 divided by that count is a weight. All copies of one name sum to 1, so SUMPRODUCT totals to 7, the number of distinct names. Value COUNTIF 1 ÷ COUNTIF Alice 2 0.5 Bob 2 0.5 Alice 2 0.5 Charlie 1 1 David 1 1 Eve 2 0.5 Bob 2 0.5 Frank 1 1 Grace 1 1 Eve 2 0.5 SUMPRODUCT = 7 totals the weights weight 1 — name appears once weight 0.5 — name appears twice

Leave a Comment