The Excel UNIQUE function can extract a list of distinct values, or a list of values that only occur once, i.e. unique values. It can return a unique or distinct list from one column or from multiple columns.
Syntax: =UNIQUE(array, [by_col], [occurs_once])
array is the range or array you want the unique values returned from.
by_col is an optional logical value (TRUE/FALSE) and allows you to compare values by row (FALSE), or by column (TRUE).
occurs_once is also an optional logical value (TRUE/FALSE) and allows you to find the truly unique values, i.e. the values that only occur once (TRUE), or all distinct values (FALSE). If you omit this argument, it will default to FALSE and return a distinct list.
Note: The UNIQUE function is part of the new Excel Dynamic Arrays family and at the time of writing, Dynamic Arrays are only available in Office 365 and are currently in beta on the Insiders channel. Excel 2019 will not have the Dynamic Array functions.
Excel UNIQUE Function Examples
Let’s say we want to find a list of distinct values from the Item column (C) in the table below:
We can write a simple UNIQUE formula like this:
You can see the results in cells B26:B30 in the image below:
The Excel UNIQUE function ‘spills’ the results into the rows below. This is the new dynamic array behaviour that occurs when the final result of the formula returns multiple values.
Note: In the example above, I’ve omitted the by_col argument, which means it will default to FALSE and compare values by row. I’ve also omitted the occurs_once argument so it has defaulted to FALSE and returned a distinct list.
Extract a list of Unique Values
If you want to find a list of values that only occur once in a list, i.e. a list of truly unique values, the occurs_once argument is set to TRUE. In the example below, you can see ‘Support’ is the only unique value in the range A2:A9:
Extracting UNIQUE Rows of Values
In the example below, you can see there are whole rows containing duplicates. Setting the by_col and occurs_once arguments to FALSE we get a list of unique rows, as shown below:
Referencing a Dynamic Array
Dynamic Arrays can be referenced using the spilled range operator, #, as shown in the example below where the COUNTA function references A19#:
The benefit of using the spilled range operator is that it automatically adjusts as the spilled area grows or contracts.
You can also use spilled range operators in the Name Manager, among other places, but you’ll want to make it an absolute reference like so:
Extracting a Distinct List in Earlier Versions of Excel
Extracting unique or distinct values from a list is a common requirement and in earlier versions of Excel you can either use an array formula, a PivotTable or Power Query, as described here.
Download the Workbook
Enter your email address below to download the sample workbook.
|Excel FILTER Function||Filter cells based on criteria.|
|Excel RANDARRAY Function||Returns an array of random numbers between 0 and 1.|
|Excel SEQUENCE Function||Returns list of sequential numbers that increment as specified.|
|Excel SORT Function||Sort cells or arrays in ascending or descending order.|
|Excel SORTBY Function||Sort cells or arrays based on criteria.|