UNIQUE Function in Excel: Extract Distinct Values Automatically

UNIQUE Table Tutorial in Excel Blogpost Feature Image
Before Excel 365, getting a distinct list from a column took complex multi-function array formulas that only experts could write. UNIQUE does it with a single formula that spills automatically, updates live, and combines effortlessly with SORT and FILTER. This guide walks through six practical examples from basic deduplication to dynamic dropdown lists powered by a spill range.

Before Excel 365, extracting a list of distinct values from a column required complex array formulas combining INDEX, MATCH, and COUNTIF — formulas that only experienced users could write or maintain. The UNIQUE function changed all of that. Type the formula once, press Enter, and Excel automatically populates a clean list of distinct values, removing every duplicate and updating the list live whenever your source data changes. This guide covers the syntax, how the dynamic spill behaviour works, and six practical examples you can use immediately.

Availability: UNIQUE is available in Microsoft 365, Excel 2024, and Excel 2021 only. It requires dynamic array support, which does not exist in Excel 2019 or earlier. For older versions, use the Advanced Filter or Remove Duplicates tools instead.

UNIQUE Function Syntax

UNIQUE takes one required argument and two optional ones that control the direction of comparison and whether to return values appearing exactly once:

=UNIQUE(array, [by_col], [exactly_once])
ArgumentRequired?What it means
array Required The range or array to extract unique values from. Can be a single column, multiple columns, or a horizontal row. Works with text, numbers, dates, and any other data type.
by_col Optional FALSE (default) — compares rows against each other, extracting unique rows vertically. TRUE — compares columns against each other, for horizontal data. Almost all real-world uses keep this at the default FALSE.
exactly_once Optional FALSE (default) — returns all distinct values, including those that appear multiple times in the source. TRUE — returns only values that appear exactly once. Values that repeat at all are excluded from the output.
How spilling works: UNIQUE returns a dynamic array that automatically fills as many cells below the formula as needed. Type once in the top cell — Excel handles the rest. The spill range updates live when source data changes. Never type anything in cells below a UNIQUE formula or you will get a #SPILL! error. Reference the spill range in other formulas using the hash operator: D2#.

Example 1: Basic Distinct List from a Column

The most common use — extract every distinct value from a column, removing all duplicates in a single formula. The result spills automatically and updates whenever the source changes.

1
Extract distinct department names from a staff list
#
A — Name
B — Department
D — Unique Depts
2
Alice
Sales
Sales
3
Ben
Sales
Engineering
4
Chloe
Engineering
HR
5
Dan
Engineering
Finance
6
Eva
HR
spilled
7
Frank
Finance
spilled
8
Grace
Sales
spilled
Type once in D2 — results spill automatically into D3:D5: =UNIQUE(B2:B8) Result: Sales, Engineering, HR, Finance (4 distinct values)
One formula in D2. Excel fills D2:D5 automatically with the four distinct departments. Add a new department to column B and the spill range grows to include it instantly — no formula changes needed.
Distinct vs exactly_once: By default UNIQUE returns all distinct values — every value that appears, even if it appears multiple times, is included once. Set exactly_once=TRUE to get only values appearing a single time. See Example 4 for a full comparison.

Example 2: SORT + UNIQUE for an Alphabetical List

UNIQUE returns values in the order they first appear in the source — not alphabetically. Wrap SORT around UNIQUE to get a sorted distinct list in a single formula. This combination is one of the most useful patterns in Excel 365.

2
Distinct values sorted A to Z in one formula
Alphabetical distinct list — SORT wraps UNIQUE: =SORT(UNIQUE(B2:B100)) Descending (Z to A) — third SORT argument is -1: =SORT(UNIQUE(B2:B100), 1, -1) Numeric — distinct amounts sorted smallest to largest: =SORT(UNIQUE(C2:C100)) Count how many distinct values exist: =COUNTA(UNIQUE(B2:B100))
SORT syntax: =SORT(array, sort_index, sort_order). Use 1 for ascending (default) and -1 for descending as the third argument. When wrapping UNIQUE, sort_index is always 1 since UNIQUE returns a single column. Both functions together still produce a single spill range that updates automatically.

Example 3: UNIQUE with FILTER — Distinct Values from a Subset

Combining UNIQUE with FILTER is where this function becomes genuinely powerful for data analysis. Filter your data to a specific subset first, then extract distinct values from that subset — all in one formula with no helper columns.

3
List distinct products sold in the North region only
A — Region
B — Product
C — Unique North Products
North
Laptop
Laptop
South
Monitor
Keyboard
North
Laptop
spilled
North
Keyboard
spilled
Distinct products in North region only: =UNIQUE(FILTER(B2:B100, A2:A100="North")) Result: Laptop, Keyboard Dynamic — region driven by cell F1: =SORT(UNIQUE(FILTER(B2:B100, A2:A100=F1))) Distinct active customers from a transaction log: =UNIQUE(FILTER(A2:A200, C2:C200="Active")) Handle no-match gracefully with fallback message in FILTER: =UNIQUE(FILTER(B2:B100, A2:A100=F1, "No results"))
FILTER narrows the data to North region rows first, then UNIQUE removes duplicates from that filtered set. One formula. No helper columns. Updates automatically when data or the region selector changes.

Example 4: exactly_once = TRUE — Find Values That Appear Once

Setting the third argument to TRUE changes the behaviour entirely. Instead of returning all distinct values, UNIQUE returns only values that appear exactly once — every repeated value is excluded. Useful for finding first-time customers, one-off transactions, or single-occurrence entries in audit data.

4
Find customers who have placed exactly one order
A — Customer
Appears
Default (distinct)
exactly_once=TRUE
Alice
3 times
Alice
excluded
Ben
1 time
Ben
Ben
Chloe
2 times
Chloe
excluded
Dan
1 time
Dan
Dan
Default — all distinct values (Alice, Ben, Chloe, Dan): =UNIQUE(A2:A10) exactly_once = TRUE — only Ben and Dan (appeared once): =UNIQUE(A2:A10, FALSE, TRUE) Count first-time customers: =COUNTA(UNIQUE(A2:A10, FALSE, TRUE))
You must supply by_col first: The arguments are positional. To reach exactly_once you must provide by_col first. Since you almost always want vertical comparison, use FALSE as a placeholder: =UNIQUE(A2:A10, FALSE, TRUE). You cannot skip to the third argument.

Example 5: Unique Rows Across Multiple Columns

Pass a multi-column range to UNIQUE and it compares entire rows — returning only rows where the full combination of values is unique. Ideal for finding unique name pairs, order combinations, or any multi-field key.

5
Extract unique first-name and last-name row combinations
A — First
B — Last
Unique row?
Reason
James
Smith
Yes
First occurrence
James
Brown
Yes
Different last name
James
Smith
No
Exact duplicate
Sarah
Lee
Yes
New combination
Unique rows — both A and B must match to be treated as a duplicate: =UNIQUE(A2:B10) Returns: James/Smith, James/Brown, Sarah/Lee Combine first and last into one column using ampersand: =UNIQUE(A2:A10&" "&B2:B10) Returns single column: "James Smith", "James Brown", "Sarah Lee" Sort unique row results alphabetically by first column: =SORT(UNIQUE(A2:B10))

Example 6: Count Distinct Values and Build a Dynamic Dropdown

Two of the most practical applications in real workbooks — counting distinct values and feeding the spill result into a data validation dropdown that updates automatically as your data changes.

6
Count distinct values and power a self-updating dropdown list
Count distinct values in column B: =COUNTA(UNIQUE(B2:B100)) Count with condition — distinct active customers in North region: =COUNTA(UNIQUE(FILTER(A2:A100, B2:B100="North"))) Dynamic dropdown setup: 1. Put this formula in D2 (outside any Excel Table): =SORT(UNIQUE(B2:B100)) 2. Select dropdown cell, go to Data > Data Validation > List. 3. Set source to: =$D$2# The # references the full spill range, however large it grows.
The $D$2# spill range reference expands and contracts automatically — your dropdown always reflects the current distinct values without any manual maintenance.
Why place UNIQUE outside a Table: Dynamic array functions cannot spill inside a structured Excel Table and will return #SPILL!. Place the UNIQUE formula in a regular cell range outside the table, even if the source data is a table column: =SORT(UNIQUE(Table1[Department])).

Troubleshooting UNIQUE Errors

#SPILL! error

Something is blocking the spill range — a value, a space character, or merged cells in a cell below the formula. Click the formula cell and look for the blue spill border outline. Clear all cells in the expected spill area, including cells that appear blank but may contain a space.

#CALC! error when combined with FILTER

No rows matched the FILTER criteria, so FILTER returned an empty array and UNIQUE had nothing to process. Add a fallback as the third argument of FILTER: =UNIQUE(FILTER(A:A, B:B="North", "No results")).

#NAME? error

UNIQUE is not available in your Excel version. It requires Excel 365, 2024, or 2021. For older versions, use Data > Advanced Filter > Copy to another location and check Unique records only as an alternative.

Result shows zeros where blanks should appear

UNIQUE treats blank cells as a value and includes them in the output as 0. Pre-filter with FILTER to exclude blanks: =UNIQUE(FILTER(A2:A100, A2:A100<>"")).

Frequently Asked Questions

  • What does the UNIQUE function do in Excel?+
    UNIQUE extracts a list of distinct values from a range or array, automatically removing duplicates. The result is a dynamic array that spills into as many cells as needed and updates automatically when the source data changes. It works with text, numbers, dates, and any other data type, and requires no special key presses — just Enter.
  • What is the difference between distinct and exactly once in UNIQUE?+
    Distinct values (default) means every value that appears in the list, included once even if it appears multiple times. Exactly once (third argument = TRUE) means values that appear a single time in the source — if a value appears two or more times it is completely excluded from the result. Use distinct for deduplication, and exactly_once for identifying one-off entries.
  • Which Excel versions support UNIQUE?+
    UNIQUE is available in Microsoft 365, Excel 2024, and Excel 2021. It does not work in Excel 2019, 2016, or earlier because those versions do not support dynamic arrays. For older versions, use the Advanced Filter (Data tab) to extract unique values to another location, or use Remove Duplicates on a copy of your data.
  • How do I sort the UNIQUE results alphabetically?+
    Wrap UNIQUE inside SORT: =SORT(UNIQUE(A2:A100)). SORT arranges results ascending by default. Add -1 as the third argument for descending order: =SORT(UNIQUE(A2:A100), 1, -1). The combined result is still a single dynamic spill range that updates automatically when source data changes.
  • How do I use UNIQUE to create a dynamic dropdown list?+
    Place =SORT(UNIQUE(B2:B100)) in a spare cell outside any Excel Table — for example D2. Then select your dropdown cell, go to Data > Data Validation > List, and enter =$D$2# as the source. The # spill range operator references the full spill automatically, so the dropdown grows or shrinks as your data changes without any manual updates.
  • Why does UNIQUE return a #SPILL! error inside an Excel Table?+
    Dynamic array functions including UNIQUE cannot spill inside a structured Excel Table. Place the UNIQUE formula in a regular cell range outside the table. You can still reference a table column as the source array: =UNIQUE(Table1[Department]) — just ensure the formula cell itself is outside the table boundaries.