
To count unique values in Google Sheets, the shortest formula is =COUNTUNIQUE(A2:A100). It returns how many different values the range has, so a column with Ann, Ben, Ann and Cara gives 3. This guide shows that formula, then the cases people actually need: counting unique values with a condition, across several columns, ignoring blanks and fixing counts that are off because of extra spaces. All sample data is made up.
COUNTUNIQUE: the basic formula
=COUNTUNIQUE(value1, [value2, ...])
Give it a range, or several ranges and values, and it counts the distinct items. Example for a list of customer names in A2:A100:
=COUNTUNIQUE(A2:A100)
Start the range below the header. If you include the header, it is counted as one more unique value.

Count unique values with a condition
COUNTUNIQUE has no condition argument. Combine it with FILTER. To count the unique customers in the East region, where regions are in column B:
=COUNTUNIQUE(FILTER(A2:A100, B2:B100="East"))
FILTER returns only the East rows, and COUNTUNIQUE counts the distinct names in them. If no row matches, FILTER returns an error, so wrap the formula in IFERROR to show 0:
=IFERROR(COUNTUNIQUE(FILTER(A2:A100, B2:B100="East")), 0)
Our guide to the FILTER function in Google Sheets has more examples of conditions.

Count unique rows across two columns
If a unique item is a pair, such as customer and product, put the columns together in one formula:
=COUNTUNIQUE(A2:A100 & "|" & B2:B100)
In Google Sheets this may need ARRAYFORMULA around the joined range, so use =COUNTUNIQUE(ARRAYFORMULA(A2:A100 & "|" & B2:B100)). The pipe character keeps "AB" plus "C" different from "A" plus "BC". Empty rows will produce a value of just the separator, so limit the range to the rows that hold data.
Another way: COUNTA with UNIQUE
=COUNTA(UNIQUE(A2:A100))
UNIQUE returns the list of distinct values and COUNTA counts them. It gives the same answer as COUNTUNIQUE for simple lists, and it is handy because you can look at the UNIQUE list itself first. See our UNIQUE function examples for how it behaves with several columns. One difference: if the range has blank cells, UNIQUE can return an empty row, and COUNTA may count it. Compare both formulas on your data.
Ignore blank cells
When your range includes empty cells, filter them out before counting:
=COUNTUNIQUE(FILTER(A2:A100, A2:A100<>""))
This makes sure an empty cell never adds to the total, whichever counting method you use.
Why your count is too high: spaces and spelling
"Ann" and "Ann " (with a trailing space) are different values. If the count is higher than you expect, clean the text first:
=COUNTUNIQUE(ARRAYFORMULA(TRIM(A2:A100)))
Different spellings, such as "Acme Ltd" and "Acme Limited", are still counted as different. Fix those in the source data. If you want to remove repeated rows instead of counting them, see how to remove duplicates in Google Sheets.

Count how often each unique value appears
Sometimes the number of unique items is not enough. To list each value with its count, use QUERY:
=QUERY(A2:A100, "select A, count(A) where A is not null group by A label count(A) 'Orders'", 0)
This gives a two column list: each unique name and how many times it appears. Sort it by adding order by count(A) desc before the label part.

Count unique values from another sheet
Point the range at the other sheet: =COUNTUNIQUE(Orders!A2:A500). If the data is in a different file, bring it in with IMPORTRANGE first and wrap that in COUNTUNIQUE. Sheets will ask you to allow access the first time.
Common mistakes
- Including the header row. It adds 1 to the count.
- Hidden spaces. Use TRIM as shown above.
- Numbers stored as text. "5" as text and 5 as a number can be seen as different. Make the column consistent.
- Counting too far down. A range like A2:A1000 with blanks needs the blank filter.
Questions and answers
Does COUNTUNIQUE ignore blank cells?
For a plain range, empty cells are not counted as a value. If you build the list with a formula that returns empty text, filter those out as shown above.
Is there a COUNTUNIQUE in Excel?
No function has that name in Excel. In Excel 365 and Excel 2021 use =COUNTA(UNIQUE(A2:A100)). In older versions, a SUMPRODUCT formula with COUNTIF does the job. Our SUMPRODUCT guide explains the base function.
How do I count unique values in a pivot table?
Google Sheets pivot tables list unique items as rows, so the row count is the unique count. For a simple number, the formulas above are faster.
Is COUNTUNIQUE case sensitive?
Test it on your data: type "Ann" and "ann" in two cells and see the result. If you need a strict case sensitive count, you will need a different approach, such as a helper column with EXACT.
