ExcelReady
CourseFunction guidesBlog
Start freeStart learning for free
ExcelReady

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

Learn

  • Course
  • Function guides
  • Blog

Product

  • Certificate

Company

  • Editorial policy
  • Contact
  • Terms
  • Privacy

© 2026 ExcelReady. All rights reserved.

  1. Blog
  2. Conditional math
  3. How to Count Unique Values in Excel

How to Count Unique Values in Excel

By ExcelReady Team·Updated October 30, 2026·6 min read

The short answer

In Excel 2021 and Microsoft 365, count unique values with =COUNTA(UNIQUE(B2:B11)): UNIQUE lists each different value once and COUNTA counts the list. Add a condition with FILTER, as in =COUNTA(UNIQUE(FILTER(B2:B11,C2:C11="East"))). In older Excel, use =SUMPRODUCT(1/COUNTIF(B2:B11,B2:B11)) instead.

Key takeaways

  • =COUNTA(UNIQUE(range)) counts distinct values in Excel 2021 and Microsoft 365.
  • UNIQUE(range,FALSE,TRUE) keeps only values that appear exactly once, which is a different question.
  • Put FILTER inside UNIQUE to count distinct values that meet a condition.
  • Blank cells add an extra item to UNIQUE, and an empty FILTER still counts as 1: guard against both.
  • =SUMPRODUCT(1/COUNTIF(range,range)) works in every version, but returns #DIV/0! if the range has blanks.
On this page+
  1. How to count unique values with COUNTA and UNIQUE
  2. How to count values that appear exactly once
  3. How to count unique values with a condition
  4. Why is my unique count one too high? (Blank cells)
  5. How to count unique values in older Excel (2019 and earlier)
  6. Count unique values without a formula
  7. Practise it

To count unique values in Excel 2021 or Microsoft 365, wrap UNIQUE in COUNTA: =COUNTA(UNIQUE(B2:B11)). UNIQUE lists each different value once, and COUNTA counts how many there are. This guide shows that formula, how to add a condition, the two traps that make the count wrong, and a formula for older versions of Excel. "How many different customers do we have?" is a common interview question, so it is worth knowing well.

How to count unique values with COUNTA and UNIQUE#

=COUNTA(UNIQUE(range)) is the quickest way to count distinct values. Here is an order list where some customers ordered more than once:

ABC
1OrderCustomerRegion
2SO-1001BrightlineEast
3SO-1002NorthwindWest
4SO-1003BrightlineEast
5SO-1004KestrelEast
6SO-1005Orchid CoWest
7SO-1006NorthwindWest
8SO-1007BrightlineEast
9SO-1008JuniperSouth
10SO-1009Maple LtdWest
11SO-1010KestrelEast

There are 10 orders. To count the different customers:

Excel formula
=COUNTA(UNIQUE(B2:B11))

UNIQUE(B2:B11) returns Brightline, Northwind, Kestrel, Orchid Co, Juniper and Maple Ltd. COUNTA counts the six names, so the result is 6. (COUNT would return 0, because it only counts numbers.)

UNIQUE needs Excel 2021, Excel for Microsoft 365 or Excel for the web. If you type =UNIQUE(B2:B11) on its own, the list spills into the cells below; see the UNIQUE function guide for how spilling works, and how to fix a #SPILL! error if something is in the way. Inside COUNTA nothing spills, because the result is one number.

How to count values that appear exactly once#

UNIQUE has an optional third argument, exactly_once. Set it to TRUE to keep only values that appear one time.

Excel formula
=COUNTA(UNIQUE(B2:B11,FALSE,TRUE))

The result is 3: Orchid Co, Juniper and Maple Ltd each ordered once. The second argument, FALSE, means "compare rows, not columns", which is right for a list that runs down a column.

These are two different questions. "How many different customers?" is 6. "How many one-time customers?" is 3. Read the task carefully before you choose.

How to count unique values with a condition#

To count distinct values that meet a condition, filter the rows first and then count what's unique. How many different customers are in the East?

Excel formula
=COUNTA(UNIQUE(FILTER(B2:B11,C2:C11="East")))

FILTER(B2:B11,C2:C11="East") returns the five East orders: Brightline, Brightline, Kestrel, Brightline, Kestrel. UNIQUE reduces that to Brightline and Kestrel, and COUNTA gives 2. Change "East" to "West" and you get 3. The FILTER function guide covers more ways to write the condition, such as (C2:C11="East")*(A2:A11<>"") for two conditions.

Watch out: an empty FILTER still counts as 1#

If no rows match, FILTER returns a #CALC! error, and COUNTA counts that error as one item. So =COUNTA(UNIQUE(FILTER(B2:B11,C2:C11="North"))) returns 1, even though there are no North orders. Guard against it by checking first:

Excel formula
=IF(COUNTIF(C2:C11,"North")=0,0,COUNTA(UNIQUE(FILTER(B2:B11,C2:C11="North"))))

This returns 0. Our COUNTIF guide explains the COUNTIF check, and the COUNTIF function reference lists its criteria rules.

Count unique values for every group#

To build a small summary with one row per region, list the regions with =UNIQUE(C2:C11) in E2. It spills East, West and South. Then in F2, count the customers for each one and fill down:

Excel formula
=COUNTA(UNIQUE(FILTER($B$2:$B$11,$C$2:$C$11=E2)))

The results are 2 for East, 3 for West and 1 for South. Lock the data ranges with dollar signs and leave E2 relative so each row checks its own region. A pivot table can give the same summary; see the Distinct Count option below.

Why is my unique count one too high? (Blank cells)#

A blank cell in the range adds one extra item to UNIQUE's list, which Excel shows as 0. COUNTA counts it, so the result is one higher than the number of real values. Remove blanks before counting:

Excel formula
=COUNTA(UNIQUE(FILTER(B2:B11,B2:B11<>"")))

The test B2:B11<>"" keeps only cells that aren't empty. Cells that hold just a space are not empty, so clean those first with TRIM, or use count non-blank cells with a condition to find them.

Also note that UNIQUE is not case-sensitive (Kestrel and KESTREL count once), but it does treat "Kestrel" and "Kestrel " (with a trailing space) as different values.

How to count unique values in older Excel (2019 and earlier)#

Without UNIQUE, use SUMPRODUCT and COUNTIF. This formula works in every version:

Excel formula
=SUMPRODUCT(1/COUNTIF(B2:B11,B2:B11))

How it works: COUNTIF(B2:B11,B2:B11) counts how often each row's value appears. Brightline appears 3 times, so each of its rows gets 1/3; Kestrel gets 1/2 twice; Juniper gets 1/1. Each customer's fractions add up to exactly 1, so the total is 6.

This version returns #DIV/0! if the range contains a blank cell. The fix adds &"" and skips blanks:

Excel formula
=SUMPRODUCT((B2:B11<>"")/COUNTIF(B2:B11,B2:B11&""))

On large ranges (tens of thousands of rows) the COUNTIF method can be slow, because it counts the whole range once for every row.

Count unique values without a formula#

Two point-and-click options are worth knowing:

  • Remove Duplicates: copy the column to a new sheet, select it, and choose Data > Remove Duplicates, then count the rows that remain. It changes the data, so always work on a copy. See UNIQUE vs Remove Duplicates for when each fits.
  • Pivot table Distinct Count (Excel for Windows): when you create the pivot table, tick Add this data to the Data Model. Then in Value Field Settings, choose Distinct Count. Without the Data Model, the option doesn't appear.

For a total by group rather than a count, such as revenue for "North or East", see SUMIFS with OR logic.

Practise it#

Try the live exercise on this page to count the different customers. Then practise UNIQUE in a live spreadsheet, including the exactly-once option, and use the COUNTIF lesson to get comfortable with the criteria that power the older formula.

Try it yourself

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

How many different customers placed orders? In G2, put UNIQUE on the Customer column (B2:B11) inside COUNTA.

fx
ABCDEFGH
1
Order
Customer
Region
Customers
2
SO-1001
Brightline
East
3
SO-1002
Northwind
West
4
SO-1003
Brightline
East
5
SO-1004
Kestrel
East
6
SO-1005
Orchid Co
West
7
SO-1006
Northwind
West
8
SO-1007
Brightline
East
9
SO-1008
Juniper
South
10
SO-1009
Maple Ltd
West
11
SO-1010
Kestrel
East
12
13
14

Tip: UNIQUE(B2:B11) lists each customer once. COUNTA around it counts that list.

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.LessonCOUNTIFCount the cells that match a condition, from exact words to number checks like ">=8".Function guideCOUNTIFCount cells that match one condition with COUNTIF: text, numbers, wildcards and cell references. Real examples and 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

What is the formula to count unique values in Excel?

+

In Excel 2021 or Microsoft 365, use =COUNTA(UNIQUE(A2:A100)). In older versions, use =SUMPRODUCT(1/COUNTIF(A2:A100,A2:A100)), as long as the range has no blank cells.

What is the difference between unique and distinct values?

+

People often mean the same thing: each different value counted once. Excel's UNIQUE can also return values that appear exactly once, using its third argument, which some people call "unique" in the strict sense.

How do I count unique values with a condition?

+

Filter first, then count: =COUNTA(UNIQUE(FILTER(B2:B11,C2:C11="East"))) counts the different customers in the East region.

Why does my unique count come out one too high?

+

The range probably contains a blank cell, which UNIQUE returns as an extra item. Remove blanks first with FILTER(range,range<>"").

Is UNIQUE case-sensitive?

+

No. UNIQUE treats "Kestrel" and "KESTREL" as the same value and keeps the first one it finds.

Sources

  • UNIQUE function - Microsoft Support
  • FILTER function - Microsoft Support
  • COUNTIF function - Microsoft Support

Written and checked by the ExcelReady Team. First published October 30, 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. How to count unique values with COUNTA and UNIQUE
  2. How to count values that appear exactly once
  3. How to count unique values with a condition
  4. Why is my unique count one too high? (Blank cells)
  5. How to count unique values in older Excel (2019 and earlier)
  6. Count unique values without a formula
  7. Practise it

Keep reading

Conditional math· 6 min read

Count Non-Blank Cells With a Condition in Excel

To count cells that are not blank, use =COUNTIF(C2:C8,"<>"), where "<>" means "not equal to nothing". To add a condition, use COUNTIFS: =COUNTIFS(B2:B8,"Sales",D2:D8,"<>") counts Sales rows whose column D is filled in. Use "" instead of "<>" to count the blank ones. COUNTA also counts non-blank cells, but takes no condition.

Conditional math· 7 min read

SUMIFS With OR Logic in Excel

SUMIFS joins every condition with AND, so for OR you combine several sums. Add two SUMIFS: =SUMIFS(E2:E9,A2:A9,"North")+SUMIFS(E2:E9,A2:A9,"East"), or use an array constant: =SUM(SUMIFS(E2:E9,A2:A9,{"North","East"})). When the OR spans two different columns, use SUMPRODUCT so rows that match both aren't counted twice.

Conditional math· 6 min read

How to Use COUNTIF in Excel (With Criteria Examples)

COUNTIF counts the cells in a range that meet one condition. Write =COUNTIF(range, criteria), for example =COUNTIF(D2:D9,"Open") to count open tickets. Put text and comparisons in double quotes, like ">=8" or "<>Low". Numbers and cell references go in without quotes. For two or more conditions, use COUNTIFS.

Don't just read about Excel. Do it.

Practise real formulas in a live spreadsheet with instant feedback. The first lessons are free, with no download.

Start learning for free