Count unique values
Count how many different values a column contains.
The formula
Excel
=SUMPRODUCT((A2:A100<>"")/COUNTIF(A2:A100, A2:A100&""))Google Sheets
=COUNTUNIQUE(A2:A100)How it works
COUNTIF(A2:A100, A2:A100&"")For each cell, how many times its value appears.
(A2:A100<>"")/…Each value contributes 1 divided by its count, so every distinct value adds up to exactly 1. Blanks add 0.
SUMPRODUCT(…)Adds it all up. Works in every Excel version.
Example
| A: Customer | Result |
|---|---|
| Acme | 3 |
| Globex | |
| Acme | |
| Initech |
Tips
- In Excel 365 a shorter version is =COUNTA(UNIQUE(FILTER(A2:A100, A2:A100<>""))).