# UNIQUE in Google Sheets: syntax and examples

URL: https://goingstellar.ro/reference/sheets/unique/

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

- `range` (range, required: yes): The range to deduplicate. Whole rows are compared.
- `by_column` (boolean, required: no): TRUE compares columns instead of rows. The default is FALSE.
- `exactly_once` (boolean, required: 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 2026-11-29.

```
=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 2026-11-29.

```
=UNIQUE(A2:A6, FALSE, TRUE)
```

Result: 

| South |
|---|
| East |

Only regions that appear exactly once. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=SORT(UNIQUE(A2:A6))
```

Result: 

| East |
|---|
| North |
| South |

Distinct regions in alphabetical order. Run in a Google Sheet (English US locale) on 2026-11-29.

```
=COUNTA(UNIQUE(A2:A6))
```

Result: `3`

How many distinct regions there are. Run in a Google Sheet (English US locale) on 2026-11-29.

## 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.

## Related functions

- [SORT](https://goingstellar.ro/reference/sheets/sort/)
- [FILTER](https://goingstellar.ro/reference/sheets/filter/)
- [SORTN](https://goingstellar.ro/reference/sheets/sortn/)
- [COUNTA](https://goingstellar.ro/reference/sheets/counta/)
- [TRANSPOSE](https://goingstellar.ro/reference/sheets/transpose/)
- [QUERY](https://goingstellar.ro/reference/sheets/query/)

## Sources

- [UNIQUE (Docs Editors Help)](https://support.google.com/docs/answer/10522653)

