Mastering the UNIQUE Excel Function: A Practical Guide

Explore the UNIQUE function in Excel to extract distinct values quickly. Learn syntax, practical examples, and how to combine with SORT, FILTER, and legacy workarounds for older versions.

XLS Library
XLS Library Team
·5 min read
Unique Function Demo - XLS Library
Quick AnswerDefinition

UNIQUE is a dynamic array function that returns distinct values from a range. In modern Excel (Microsoft 365/Excel 2021+), use =UNIQUE(range) and optionally specify by_col and exactly_once for advanced filtering. For older Excel versions, use legacy workarounds with FREQUENCY, INDEX, MATCH, and COUNTIF. This guide covers syntax, examples, and best practices for real-world data tasks.

What is the UNIQUE function and why it matters

The UNIQUE function is a dynamic array staple that returns only distinct values from a range. It automatically spills results into adjacent cells, simplifying data cleaning tasks like deduping lists, preparing dropdowns, and feeding dashboards. Understanding its basics unlocks more advanced workflows across data preparation and analysis.

Excel Formula
=UNIQUE(A2:A20)
  • This returns all unique values from A2:A20 in a vertical spill.
  • If you want to filter by column instead of row, you can use the by_col parameter:
Excel Formula
=UNIQUE(A2:E2, TRUE, FALSE)
  • Exactly_once can be set to TRUE to return each value only once, excluding duplicates.

Notes:

  • By default, UNIQUE spills automatically; you can reference the spill range like B2 to capture results.
  • If the input contains blanks, they are considered a value and will appear in the output unless filtered.

Practical uses: deduplicating lists, preparing dropdowns, and data validation

Deduplicating lists to feed unique item lists is a common task in data prep. Use UNIQUE in combination with SORT to produce clean, ordered lists ready for dropdowns and data validation:

Excel Formula
=SORT(UNIQUE(Products!A2:A100))

This yields a sorted list of distinct products from the Products sheet. For dynamic dashboards, combine UNIQUE with FILTER to keep only relevant items:

Excel Formula
=FILTER(SORT(UNIQUE(Orders!A2:A500)), Orders!A2:A500<>"")

To extract unique values by column (for column-based deduplication), set by_col to TRUE:

Excel Formula
=UNIQUE(Inventory!B2:D200, TRUE)
  • You can cascade these patterns to build self-updating controls in dashboards and reports.

Working with multiple columns: unique rows vs unique columns

UNIQUE can operate on 2D ranges. By default, it returns unique rows from a table or range:

Excel Formula
=UNIQUE(A2:C100) // returns unique rows

If you want to identify unique columns instead of rows, set by_col to TRUE:

Excel Formula
=UNIQUE(A2:C100, TRUE) // returns unique columns

This distinction is essential when your data is structured with multiple fields per row and you want to preserve row integrity or assess column-level uniqueness for summaries.

Older Excel workarounds without UNIQUE: using FREQUENCY, MATCH, INDEX

Some readers still work with legacy Excel versions lacking dynamic arrays. A classic approach uses a combination of INDEX, MATCH, COUNTIF, and FREQUENCY in an array formula to extract unique items. Enter with Ctrl+Shift+Enter (CSE) to create an array formula:

Excel Formula
{=INDEX($A$2:$A$100, MATCH(0, COUNTIF($D$1:D1, $A$2:$A$100), 0))}

This returns a single unique value per row, and you can drag the formula down to fill more unique values. Keep in mind that this method is more brittle, slower on large datasets, and harder to maintain than modern UNIQUE formulas. If you must support older workbooks, consider upgrading the data-processing logic or using Power Query for de-duplication.

Older Excel workarounds continued: robust patterns with INDEX and CHOOSE

To simulate UNIQUE across larger datasets, you can combine INDEX with ROW and MATCH to build a dynamic list of unique records without CSE, though this remains less straightforward than using UNIQUE. Example patterns may involve helper columns and custom row counters, but they are inherently more verbose and error-prone than modern alternatives. When possible, migrate users to a version that supports dynamic arrays to reduce maintenance overhead.

Advanced combos: FILTER, SORT, and SEQUENCE for dynamic reporting

Dynamic array-enabled Excel lets you blend UNIQUE with FILTER, SORT, and SEQUENCE to produce powerful, compact reports. For instance, to return sorted, nonblank uniques from a filtered dataset:

Excel Formula
=LET(r, A2:A100, FILTER(SORT(UNIQUE(r)), r<>""))

Or to generate a list of the first N unique items:

Excel Formula
=LET(r, A2:A100, SEQUENCE(5,1), INDEX(UNIQUE(r), SEQUENCE(5,1)))

These patterns enable compact, readable formulas that adapt as data changes, a core benefit of the dynamic array era. Remember that not all environments support SEQUENCE or LET; for those, fall back to stepwise combinations of SORT and UNIQUE.

Common patterns and real-world examples

In practice, you’ll often combine UNIQUE with conditionals to derive context-specific lists. For example, to pull unique values that meet a criterion in a second column:

Excel Formula
=LET(t, FILTER(A2:A100, B2:B100="Yes"), UNIQUE(t))

This pattern supports dashboards that slice data by category, status, or flag while keeping the output compact and easy to maintain. When datasets include blanks or errors, layer in IFERROR to present clean results or a helpful message:

Excel Formula
=IFERROR(UNIQUE(FILTER(A2:A100, ISNUMBER(A2:A100))), "No data")

These techniques emphasize the flexibility of UNIQUE in practical data workflows.

Steps

Estimated time: 60 minutes

  1. 1

    Verify Excel version and data readiness

    Check that you’re running Excel 365/2021+ to use the dynamic array features. Prepare a clean dataset in a single column or a 2D table with headers for practice.

    Tip: If your data contains blanks, decide whether to treat blanks as a value or filter them out first.
  2. 2

    Apply a basic UNIQUE formula

    Choose a single-column range and enter =UNIQUE(A2:A20) to see how the values spill. Adjust the range to match your data, and note the automatic spill behavior.

    Tip: Use the spill range reference to feed downstream formulas or charts.
  3. 3

    Control the output with by_col and exactly_once

    Experiment with the optional by_col and exactly_once parameters to tailor whether you deduplicate by column and whether to include only unique occurrences.

    Tip: In 2D arrays, understand whether you want unique rows or unique columns for your analysis.
  4. 4

    Combine UNIQUE with SORT and FILTER

    Wrap UNIQUE with SORT to present an ordered list; use FILTER to exclude blanks or apply a criterion before deduping.

    Tip: This pattern is ideal for drop-down lists and dynamic dashboards.
  5. 5

    Build legacy workarounds if needed

    For older Excel versions, implement array formulas with INDEX/MATCH and COUNTIF to simulate UNIQUE. Document these steps for future maintenance.

    Tip: Consider migrating users to a modern environment to simplify maintenance.
  6. 6

    Validate results and edge cases

    Test with duplicates, blanks, and errors. Use IFERROR to present friendly messages when data is missing or invalid.

    Tip: Edge-case handling reduces user confusion in dashboards.
Pro Tip: Leverage dynamic arrays to spill results automatically into adjacent cells without manual copying.
Warning: UNIQUE is not available in older Excel versions; use legacy workarounds or Power Query for de-duplication.
Note: Blanks are treated as a value by default; filter or replace blanks if you don’t want them in the output.

Prerequisites

Required

Optional

  • Optional: familiarity with legacy workarounds (for older versions)
    Optional
  • Power Query access for large-scale de-duplication (optional)
    Optional

Keyboard Shortcuts

ActionShortcut
CopyCopy selected cell or rangeCtrl+C
PastePaste into a target rangeCtrl+V
Enter Edit ModeEdit the active cell formulaF2
Fill DownCopy the value/formula from the above cell downwardCtrl+D
UndoUndo last actionCtrl+Z
AutoSumInsert sum quickly for a row/columnAlt+=
Recalculate workbookRecalculate all formulas in the workbookF9

People Also Ask

What is the UNIQUE function and what does it do in Excel?

UNIQUE is a dynamic array function that returns distinct values from a given range or array. It spills the results into adjacent cells, simplifying de-duplication tasks and enabling cleaner data feeds for dashboards and dropdowns.

UNIQUE pulls out the distinct values from your data and spills them into adjacent cells automatically. It makes data cleaning faster and more reliable.

Which Excel versions support UNIQUE?

UNIQUE is available in Excel 365 and Excel 2021+. Older versions do not support dynamic arrays and require alternative methods.

UNIQUE works in the latest Excel versions. If you’re on older software, you’ll need different techniques.

How can I get unique rows instead of unique columns?

By default, =UNIQUE(range) returns unique rows. Set the by_col parameter to TRUE to retrieve unique columns when dealing with a transposed dataset.

To get unique rows, simply use the default. For unique columns, set by_col to TRUE.

What about blanks in the data?

Blanks are treated as a value by UNIQUE. If you want to exclude them, filter them out either before or after deduping, or wrap with FILTER to remove blanks.

Blanks count as a value for UNIQUE, so filter them out if you don’t want blanks in the results.

Can UNIQUE be used with other functions like SORT and FILTER?

Yes. Common patterns include SORT(UNIQUE(...)) for ordered results and FILTER(UNIQUE(...), condition) to combine deduplication with filtering.

Absolutely. Pair UNIQUE with SORT and FILTER for powerful, compact data workflows.

The Essentials

  • Use UNIQUE to quickly extract distinct values.
  • Combine with SORT for ordered results and with FILTER for conditional deduplication.
  • Know when to apply by_col to handle multi-dimensional data.
  • For older Excel, plan a migration path or use stable legacy workarounds.

Related Articles