Extract unique values from range
=UNIQUE(array, [by_col], [exactly_once])
| Parameter | Description |
|---|---|
array |
Range or array from which to extract unique values. |
by_col |
[optional] How to compare and extract. FALSE = by row (default); TRUE = by column. |
exactly_once |
[optional] TRUE = values that occur once, FALSE= all unique values (default). |
Using the UNIQUE function is straightforward. Just provide a range or array:
=UNIQUE(A1:A10) // unique values from A1:A10
Here are a few variations, which are explained in more detail below:
=UNIQUE(A1:B10) // unique rows from two columns
=UNIQUE(A1:E1,TRUE) // unique values from horizontal range
=UNIQUE(A1:A10,,TRUE) // unique values that appear exactly once
=SORT(UNIQUE(A1:A10)) // unique values, sorted
In the worksheet below, the goal is to extract a list of unique colors from the range B5:B16. The formula in D5 is:
=UNIQUE(B5:B16)
By default, UNIQUE compares values by row. To extract unique values from horizontal data (arranged in columns), set by_col to TRUE. In the worksheet b
=UNIQUE(C4:I4,TRUE)
With by_col set to TRUE, UNIQUE compares values across columns instead of down rows. The result spills horizontally, returning the 5 unique colors: re
=TRANSPOSE(UNIQUE(C4:I4,TRUE))
A common pattern is to combine UNIQUE with SORT to return unique values in alphabetical or numerical order. In the worksheet below, the goal is to ext
=SORT(UNIQUE(B5:B16))