Google Sheets function · Filter and sort
UNIQUE in Google Sheets: syntax and examples
UNIQUE removes duplicate rows from a range and spills the rest in order of first appearance. With a second and third argument it can compare columns instead of rows, or keep only values that appear exactly once. Comparison is case-sensitive and exact.
Syntax
UNIQUE(range, [by_column], [exactly_once])
Arguments
| Argument | Type | Required | What it does |
|---|---|---|---|
range | range | yes | The range to deduplicate. Whole rows are compared. |
by_column | boolean | no | TRUE compares columns instead of rows. The default is FALSE. |
exactly_once | boolean | no | TRUE keeps only rows that appear one time. The default is FALSE. |
Examples
The examples use this table, starting in A1:
| Region | Product | Units |
| North | Lamp | 10 |
| South | Chair | 4 |
| North | Chair | 6 |
| North | Lamp | 3 |
| East | Lamp | 8 |
=UNIQUE(A2:A6)Result:
| North |
| South |
| East |
The distinct regions, in order of first appearance.
Run in a Google Sheet (English US locale) on .
=UNIQUE(A2:B6)Result:
| North | Lamp |
| South | Chair |
| North | Chair |
| East | Lamp |
Distinct region and product pairs. Two columns are compared together.
Run in a Google Sheet (English US locale) on .
=UNIQUE(A2:A6, FALSE, TRUE)Result:
| South |
| East |
Only regions that appear exactly once.
Run in a Google Sheet (English US locale) on .
=SORT(UNIQUE(A2:A6))Result:
| East |
| North |
| South |
Distinct regions in alphabetical order.
Run in a Google Sheet (English US locale) on .
=COUNTA(UNIQUE(A2:A6))Result: 3
How many distinct regions there are.
Run in a Google Sheet (English US locale) on .
Common errors
- Comparison is case-sensitive. "a" and "A" count as two different values.
- A trailing space makes a different value. "a " is not the same as "a", so TRIM the data first.
- UNIQUE with exactly_once set to TRUE returns #REF! when no row appears only once.
- A blank cell is a value too. UNIQUE on x, blank, x returns two rows: x and an empty one.
Compared with Excel
Excel 365 has UNIQUE with the same three arguments.
Questions and answers
How do I list unique values in alphabetical order?
Wrap it: SORT(UNIQUE(A2:A6)). UNIQUE keeps order of first appearance, and SORT then orders the list.