What UNIQUE does
UNIQUE lists each different value in a range once, in the order it first appears. =UNIQUE(A2:A8) turns a list of invoices, where the same customers come up again and again, into a list of the customers with each one named once. To count the unique values instead of listing them, wrap it in COUNTA: =COUNTA(UNIQUE(A2:A8)).
It works like reading down the column and noting each name the first time it comes up. The result spills into the cells below the formula, as many as it needs, and it changes when the source does: a new customer joins the list, and one that no longer appears drops out.
Capitals don’t make two values different, so “Harlow Dental” and “HARLOW DENTAL” count as one. A space does, so “Pine & Co” and “Pine & Co ” with a space at the end count as two.
Syntax
arrayRequired- The range to take values from, such as the customer column
A2:A8. Given several columns, UNIQUE compares whole rows. by_colOptional- Leave it out to compare rows, which is what a list down a column needs.
TRUEcompares columns instead, for data that runs across the sheet. exactly_onceOptionalTRUEreturns only the values that appear once in the range. Left out, orFALSE, it returns every value once.
Example: list each customer once
A service company’s invoice log names the customer on every row. The formula in A11 lists each customer once.
To total each customer beside the list, put =SUMIF(A2:A8,A11#,B2:B8) in B11. The A11# hands SUMIF the whole spilled list, so it returns one total per customer, 485 for Harlow Dental on the first row, and it grows or shrinks with the list.
Example: count the unique values
To know how many different customers there were, count the list UNIQUE returns.
COUNTA counts text and numbers alike. When the range can hold empty cells, filter them out first, as in =COUNTA(UNIQUE(FILTER(A2:A50,A2:A50<>""))), so the count covers names only.
Values that appear only once
With TRUE as the third argument, UNIQUE keeps only the values that appear exactly once. On the invoice log above, =UNIQUE(A2:A8,,TRUE) returns Westbrook Gym and Lumen Studio, the two customers with a single invoice. The two commas leave out the second argument, by_col.
UNIQUE with a condition, and without blanks
UNIQUE has no condition of its own, so give it a filtered list. =UNIQUE(FILTER(A2:A50,C2:C50="West")) lists each customer once from the rows where column C says West.
An empty cell in the range comes through as one extra item, which Excel shows as 0. The same FILTER leaves blanks out: =UNIQUE(FILTER(A2:A50,A2:A50<>"")).
Given two columns, as in =UNIQUE(A2:B50), UNIQUE compares whole rows and returns each different pair once, such as each customer with each product they bought.
Common mistakes
=UNIQUE(A1:A8)starts on the heading row, so “Customer” joins the list. Start the range below the headings.- A stray space at the end of a name makes a second entry for the same customer. Clean the column with TRIM, or use
=UNIQUE(TRIM(A2:A8)). =UNIQUE(A2:A8,TRUE)puts TRUE in the second argument, which compares columns, so a single column comes back unchanged. TRUE for values that appear once goes third:=UNIQUE(A2:A8,,TRUE).- An entry typed in the cells below the formula blocks the list, and the formula shows
#SPILL!. Clear the way, or write the formula where there’s room. - UNIQUE isn’t in Excel 2019 or earlier, where the formula shows
#NAME?. There, copy the column and use Data > Remove Duplicates on the copy, or summarize the list with a PivotTable.
Frequently asked questions
How do I count unique values in Excel?
Wrap UNIQUE in COUNTA: =COUNTA(UNIQUE(A2:A50)) counts the different values in A2:A50. If the range has empty cells, filter them out first: =COUNTA(UNIQUE(FILTER(A2:A50,A2:A50<>""))).
Why does UNIQUE return a 0?
The range includes an empty cell, which UNIQUE lists as one more item, shown as 0. Leave the blanks out with FILTER: =UNIQUE(FILTER(A2:A50,A2:A50<>"")).
Can UNIQUE work with multiple columns?
Yes. Given a range two or more columns wide, it returns each different row once, so =UNIQUE(A2:B50) lists each combination of the two columns.
How do I list unique values in alphabetical order?
Wrap UNIQUE in SORT: =SORT(UNIQUE(A2:A50)) lists each value once, from A to Z.
What is the difference between UNIQUE and Remove Duplicates?
Remove Duplicates deletes the repeats from the data itself, once. UNIQUE leaves the data as it is and builds a separate list that updates when the data changes.
Why is UNIQUE not available in my Excel?
UNIQUE is in Microsoft 365, Excel for the web, and Excel 2021 or later. Excel 2019 and earlier don’t have it, so the formula shows #NAME?.