Sub topic 7
UNIQUE: Remove Duplicate Values and Rows
Prerequisites: You should know how to enter Google Sheets formulas, use ranges such as B2:B, and recognize a header row. You should also understand that array formulas can return multiple cells from one formula.
UNIQUE returns a list with duplicate values removed. The result is an array, so Google Sheets spills it into the cells below or beside the formula cell.
Return each value once
Suppose column B contains region names:
| Region |
|---|
| West |
| East |
| West |
| South |
| East |
Enter this formula in an empty cell:
=UNIQUE(B2:B)The result is:
| Result |
|---|
| West |
| East |
| South |
UNIQUE keeps the order of first appearance. It does not sort the values alphabetically. To sort the result, wrap UNIQUE in SORT:
=SORT(UNIQUE(B2:B), 1, TRUE)The inner UNIQUE function removes duplicates first. The outer SORT function then orders the remaining values by their first, and only, column.
Remove duplicate rows
UNIQUE can compare complete rows when the input range has several columns. For example:
| Region | Product | Sales |
|---|---|---|
| West | Keyboard | 1200 |
| East | Mouse | 800 |
| West | Keyboard | 1200 |
| West | Monitor | 1500 |
Use:
=UNIQUE(A2:C)The repeated West–Keyboard–1200 row appears only once. Google Sheets considers two rows duplicates only when every value in the selected columns matches.
If you want unique combinations of only Region and Product, select those columns instead:
=UNIQUE(A2:B)The Sales value is then ignored when Google Sheets compares rows.
Return values that appear exactly once
The third argument, exactly_once, changes UNIQUE from “keep one copy” to “keep only values with no duplicates.”
=UNIQUE(B2:B, FALSE, TRUE)The second argument, by_column, is FALSE, so Google Sheets examines rows. The third argument is TRUE, so a value remains only if it appears exactly one time.
With the earlier region list, the result is:
| Result |
|---|
| South |
West and East are excluded because each appears twice.
This option is useful for finding one-time entries, such as customers with a single order or categories that occur only once.
Understand the arguments
The complete syntax is:
=UNIQUE(range, [by_column], [exactly_once])| Argument | Meaning |
|---|---|
| range | The values or rows to examine |
| by_column | FALSE compares rows; TRUE compares columns |
| exactly_once | FALSE keeps one copy; TRUE keeps only values occurring once |
The bracketed arguments are optional. For normal vertical lists, leave by_column as FALSE or omit it.
=UNIQUE(B2:B)This is equivalent to:
=UNIQUE(B2:B, FALSE, FALSE)For a horizontal range, use TRUE for by_column:
=UNIQUE(B1:F1, TRUE)This compares columns and returns distinct columns.
How UNIQUE fits with other functions
UNIQUE removes repeated values. FILTER decides which rows qualify. SORT controls the order. You can combine them when a report needs all three behaviors.
For example, this formula returns distinct regions that have sales of at least 1000, in alphabetical order:
=SORT(UNIQUE(FILTER(B2:B, C2:C>=1000)), 1, TRUE)Google Sheets evaluates the functions from the inside outward:
- FILTER keeps rows where sales are at least 1000.
- UNIQUE removes repeated regions.
- SORT orders the remaining regions.
Exercise
Column B contains West, East, West, South, East. Write a formula that returns only the region names that appear exactly once.
Show answer
=UNIQUE(B2:B, FALSE, TRUE)