Google Sheets function · Math
COUNTUNIQUE in Google Sheets: syntax and examples
COUNTUNIQUE returns how many different values appear in the ranges you give it. A range with several columns is pooled into one list, so use a joined column to count combinations.
Syntax
COUNTUNIQUE(value1, [value2, ...])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
value1 | any | yes | A value or range. Duplicates are counted once. |
value2, ... | any | no | More values or ranges, pooled with the first one before counting. |
Examples
The examples use this table, starting in A1:
| Customer | City | Item | Qty |
| Ana | Cluj | Lamp | 2 |
| Bob | Iasi | Lamp | 1 |
| Ana | Cluj | Chair | 1 |
| Cris | Cluj | Lamp | 3 |
| Bob | Brasov | Lamp | 1 |
=COUNTUNIQUE(A2:A6)Result: 3
Distinct customers: Ana, Bob and Cris.
Run in a Google Sheet (English US locale) on .
=COUNTUNIQUE(B2:B6)Result: 3
Distinct cities: Cluj, Iasi, Brasov.
Run in a Google Sheet (English US locale) on .
=COUNTUNIQUE(A2:B6)Result: 6
A two-column range pools both columns: three customers and three cities.
Run in a Google Sheet (English US locale) on .
=COUNTUNIQUE(A2:A6, "Dan")Result: 4
A second argument adds a new value to the pool.
Run in a Google Sheet (English US locale) on .
=COUNTUNIQUE(ARRAYFORMULA(A2:A6&"-"&B2:B6))Result: 4
Distinct customer and city pairs: the text is joined row by row first.
Run in a Google Sheet (English US locale) on .
Common errors
- A multi-column range is not counted by row. A2:B6 pools both columns. To count row combinations, join them first with ARRAYFORMULA(A2:A6&"-"&B2:B6).
- With no argument, COUNTUNIQUE returns #N/A.
- Blank cells are not counted. A range with no values at all returns 0, not an error, so a count of 0 can mean the range is empty.
- The comparison is case sensitive, so Ana, ANA and ana count as three different values. Wrap the range in ARRAYFORMULA(LOWER(...)) first to merge them.
Compared with Excel
Excel has no COUNTUNIQUE. Use COUNTA(UNIQUE(range)) in Excel 365, or SUMPRODUCT(1/COUNTIF(range, range)) in older versions.
Questions and answers
How do I count unique values that meet a condition?
Wrap FILTER inside it: COUNTUNIQUE(FILTER(A2:A6, C2:C6="Chair")).