ExcelReady
CourseMock testsFunction guidesBlog
Start freeStart learning for free
ExcelReady

Be Excel-ready before day one. Hands-on practice in your browser, with instant feedback.

Learn

  • Course
  • Mock tests
  • Function guides
  • Blog

Test prep

  • Excel level test
  • Excel test practice
  • Free screening quiz
  • Certificate

Company

  • About
  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Dynamic arrays
  3. UNIQUE With Criteria: List Distinct Values That Match

UNIQUE With Criteria: List Distinct Values That Match

By ExcelReady Team·Updated November 2, 2026·6 min read

The short answer

UNIQUE has no criteria argument, so filter first and then remove duplicates: =UNIQUE(FILTER(A2:A8,B2:B8="North")) lists each North customer once. FILTER keeps the rows that match, and UNIQUE drops the repeats. Wrap it in SORT for an A to Z list, or in ROWS to count the results. Both functions need Excel 2021 or Microsoft 365.

Key takeaways

  • Put FILTER inside UNIQUE: FILTER picks the matching rows, UNIQUE removes repeats.
  • Multiply conditions for AND, add them for OR, just as in FILTER on its own.
  • Wrap the formula in SORT to get the distinct values in A to Z order.
  • ROWS(UNIQUE(FILTER(...))) counts the distinct matches; wrap it in IFERROR for zero matches.
  • UNIQUE, FILTER and SORT need Excel 2021 or Microsoft 365.
On this page+
  1. The sample data
  2. How to use UNIQUE with criteria
  3. How to sort the unique list
  4. How to use UNIQUE with multiple criteria
  5. How to count unique values with criteria
  6. How to return unique rows from several columns
  7. Why does UNIQUE with FILTER show an error?
  8. Practise it

UNIQUE lists each value once, but it has no criteria argument. To use UNIQUE with criteria in Excel, put FILTER inside it: FILTER keeps only the rows that match your condition, and UNIQUE removes the repeats from what is left. This guide shows the basic formula, then sorting, multiple conditions, counting and what to do in older versions of Excel.

The sample data#

Every example uses this order list in A1:C8:

ABC
1CustomerRegionProduct
2AcmeNorthPaper
3BirchSouthInk
4AcmeNorthInk
5CedarNorthPaper
6BirchSouthPaper
7DeltaSouthToner
8CedarNorthToner

Customers appear more than once because each row is an order. The question is always the same: which different customers match the condition?

UNIQUE, FILTER and SORT are dynamic array functions. They need Excel 2021, Excel 2024 or Microsoft 365, and their results spill, which means they fill as many cells below as they need.

How to use UNIQUE with criteria#

Put the condition in FILTER and wrap FILTER in UNIQUE. To list the customers in the North region, click E2 and type:

Excel formula
=UNIQUE(FILTER(A2:A8,B2:B8="North"))

The result spills into two cells: Acme and Cedar. Here is what happens, from the inside out:

  1. B2:B8="North" checks each row and gives TRUE or FALSE.
  2. FILTER keeps the customers from the TRUE rows: Acme, Acme, Cedar, Cedar.
  3. UNIQUE removes the repeats: Acme, Cedar.

The FILTER function guide and the UNIQUE function guide cover each function's arguments on its own.

To make the condition easy to change, type the region in a cell, such as G1, and point at it: =UNIQUE(FILTER(A2:A8,B2:B8=G1)). Type South in G1 and the list changes to Birch and Delta.

How to sort the unique list#

Wrap the whole formula in SORT to get the values in A to Z order. To list every customer who bought Paper:

Excel formula
=SORT(UNIQUE(FILTER(A2:A8,C2:C8="Paper")))

The result is Acme, Birch, Cedar. Without SORT, UNIQUE keeps the order in which the values first appear, which here would be Acme, Cedar, Birch. For Z to A, use SORT(...,,-1), with -1 as the third argument.

How to use UNIQUE with multiple criteria#

Combine conditions inside FILTER: multiply them for AND, add them for OR. Each condition goes in its own brackets.

North customers who bought Toner (AND):

Excel formula
=UNIQUE(FILTER(A2:A8,(B2:B8="North")*(C2:C8="Toner")))

The result is Cedar, the only row that matches both.

Customers in the South or who bought Toner (OR):

Excel formula
=UNIQUE(FILTER(A2:A8,(B2:B8="South")+(C2:C8="Toner")))

FILTER keeps rows 3, 6, 7 and 8, and UNIQUE returns Birch, Delta and Cedar. The article on FILTER with multiple criteria explains why * means AND and + means OR, and why the AND() and OR() functions don't work here. The same pattern works with date conditions, as shown in how to filter by date.

Criteria that match part of the text#

FILTER has no wildcards, so use SEARCH for "contains" conditions. To list customers whose product contains "ink":

Excel formula
=UNIQUE(FILTER(A2:A8,ISNUMBER(SEARCH("ink",C2:C8))))

SEARCH returns a position when it finds the text and an error when it doesn't, and ISNUMBER turns that into TRUE or FALSE. The result is Birch and Acme. SEARCH ignores capitals; use FIND for a case-sensitive match. More patterns are in FILTER contains text.

How to count unique values with criteria#

Wrap the formula in ROWS to count how many distinct values match. To count the different South customers:

Excel formula
=ROWS(UNIQUE(FILTER(A2:A8,B2:B8="South")))

The result is 2 (Birch and Delta). COUNTA instead of ROWS gives the same answer.

Watch out when nothing matches. FILTER then returns a #CALC! error, and the count shows an error too. Wrap it so the answer is 0:

Excel formula
=IFERROR(ROWS(UNIQUE(FILTER(A2:A8,B2:B8="East"))),0)

Don't solve this with FILTER's third argument, such as "None". ROWS would count "None" as one row and return 1. For more ways to count distinct values, including with several conditions, see how to count unique values with criteria.

How to return unique rows from several columns#

Give FILTER more than one column and UNIQUE removes duplicate rows, not just duplicate values. To see which customer and region pairs bought Paper:

Excel formula
=UNIQUE(FILTER(A2:B8,C2:C8="Paper"))

The result spills into two columns and three rows: Acme / North, Cedar / North and Birch / South. A row is only removed when every column matches another row.

If the data has empty cells, FILTER can return them as 0. Add a condition to skip them: (B2:B8="North")*(A2:A8<>"").

Why does UNIQUE with FILTER show an error?#

Each error points to one specific cause:

  • #SPILL!: the cells where the list should spill aren't empty. Clear the cells below the formula.
  • #CALC!: no rows match the condition. Check the spelling and spaces in the data, or add an IFERROR.
  • #NAME?: your version of Excel doesn't have UNIQUE or FILTER. Use one of the methods below.
  • #VALUE!: the ranges are different sizes, such as A2:A8 and B2:B9. Make them match.

In Excel 2019 and older, use a pivot table: put the criteria field (Region) in Filters and the value field (Customer) in Rows, and each customer appears once. You can also use Data > Advanced with Unique records only and a small criteria range. Neither updates by itself, so refresh or rerun it when the data changes. If you need totals rather than a list, the article on filtering and summing in one formula shows the next step.

Practise it#

FILTER and UNIQUE are quick to learn and save a lot of copying and pasting. Practise UNIQUE in a live spreadsheet: you build distinct lists and the lesson checks each formula instantly. Then practise the FILTER function with one and several conditions.

Try it yourself

This is a live spreadsheet. Type the formula in the green cell and press Enter.

How many different customers are in the South region? In E2, filter the Customer column (A2:A8) to South rows, remove repeats with UNIQUE, and count the result with ROWS.

fx
ABCDEF
1
Customer
Region
Product
2
Acme
North
Paper
South customers
3
Birch
South
Ink
4
Acme
North
Ink
5
Cedar
North
Paper
6
Birch
South
Paper
7
Delta
South
Toner
8
Cedar
North
Toner
9
10
11

Tip: Work from the inside out: FILTER(A2:A8,B2:B8="South"), then UNIQUE around it, then ROWS around that.

Practise this in a lesson

LessonUNIQUE: list and count distinct valuesPull a clean list of distinct regions or customers with UNIQUE, then count them with COUNTA.LessonFILTER: pull matching rows with a formulaReturn every row that meets one or more conditions with FILTER, and show a friendly message when nothing matches.Function guideUNIQUEList distinct values with Excel's UNIQUE, count them with COUNTA, or find items that appear only once. Examples plus a live exercise.Function guideFILTERReturn every row that matches a condition with Excel's FILTER. Multiple criteria, empty results and #SPILL! explained, with live practice.

Frequently asked questions

How do I get unique values based on criteria in Excel?

+

Wrap FILTER in UNIQUE: =UNIQUE(FILTER(A2:A8,B2:B8="North")). FILTER returns only the rows that meet the condition, and UNIQUE lists each value from those rows once.

Can UNIQUE use multiple criteria?

+

Yes, through FILTER. Multiply the conditions for AND, as in (B2:B8="North")*(C2:C8="Paper"), or add them for OR. Then wrap the FILTER in UNIQUE.

How do I count unique values with criteria?

+

Use =ROWS(UNIQUE(FILTER(A2:A8,B2:B8="North"))). Wrap it in IFERROR(...,0) so the count shows 0 instead of an error when nothing matches.

How do I get unique values with criteria in older Excel?

+

Without UNIQUE and FILTER, use a pivot table with the criteria field in Filters and the value field in Rows, or use Data > Advanced filter with Unique records only and a criteria range.

Sources

  • UNIQUE function - Microsoft Support
  • FILTER function - Microsoft Support
  • Dynamic array formulas and spilled array behavior - Microsoft Support

Written and checked by the ExcelReady Team. First published November 2, 2026. The practice exercise runs in the same formula engine as our lessons. Found a mistake? Read our editorial policy or email hello@excelready.app.

On this page

  1. The sample data
  2. How to use UNIQUE with criteria
  3. How to sort the unique list
  4. How to use UNIQUE with multiple criteria
  5. How to count unique values with criteria
  6. How to return unique rows from several columns
  7. Why does UNIQUE with FILTER show an error?
  8. Practise it

Keep reading

Dynamic arrays· 6 min read

Count Unique Values With Criteria in Excel

Filter the rows that meet your condition, keep the unique values, then count them: =COUNTA(UNIQUE(FILTER(B2:B8,A2:A8="North"))) counts the different customers in the North region. Multiply conditions inside FILTER for AND logic. This needs Excel 2021 or Microsoft 365; in older versions, use SUMPRODUCT with COUNTIFS.

Dynamic arrays· 6 min read

FILTER With Multiple Criteria: AND and OR

To use the FILTER function with multiple criteria, put each condition in brackets and combine them. Multiply for AND: =FILTER(A2:D8,(B2:B8="East")*(C2:C8="Laptop")). Add for OR: =FILTER(A2:D8,(B2:B8="East")+(B2:B8="West")). Mix them with extra brackets. Don't use the AND and OR functions inside FILTER, because they return one result, not one per row.

Dynamic arrays· 6 min read

Sum, Count or Average FILTER Results in Excel

To sum FILTER results in Excel, put FILTER inside SUM: =SUM(FILTER(D2:D9,B2:B9="East")) adds the sales of East rows only. Swap SUM for COUNT, AVERAGE or MAX for other answers. Add 0 as FILTER's third argument so no matches return 0 instead of #CALC!. To total rows left visible by the filter buttons, use =SUBTOTAL(109,D2:D9).

More on dynamic arrays

  • LAMBDA Function in Excel: Write Your Own Functions
  • LET Function in Excel: Name the Parts of a Formula
  • List All Matching Values in One Cell
  • How to Randomize a List in Excel With SORTBY
  • How to Reverse the Order of a List in Excel
  • The SEQUENCE Function in Excel
All dynamic arrays articles →

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback, right in your browser. Nothing to download.

Start learning for free