fxExcelReps

← How-to guides

How to Count Unique Values in Excel

In Microsoft 365 and Excel 2021: =COUNTA(UNIQUE(A2:A100)). UNIQUE lists each value once and COUNTA counts the list. In older versions, =SUMPRODUCT(1/COUNTIF(A2:A100, A2:A100)) gives the same answer.

{"cells": {"A1": "Question", "A10": "Elm Studio", "A11": "Cedar Foods", "A12": "Alder Trading", "A13": "Birch Logistics", "A14": "Elm Studio", "A15": "Fern Dental", "A2": "Different clients", "A3": "Older Excel", "A4": "Clients in North", "A7": "Client", "A8": "Elm Studio", "A9": "Alder Trading", "B1": "Answer", "B10": "North", "B11": "East", "B12": "South", "B13": "North", "B14": "North", "B15": "North", "B2": "=COUNTA(UNIQUE(A8:A15))", "B3": "=SUMPRODUCT(1/COUNTIF(A8:A15,A8:A15))", "B4": "=COUNTA(UNIQUE(FILTER(A8:A15,B8:B15=\"North\")))", "B7": "Region", "B8": "North", "B9": "South"}, "focus": "B2", "note": "Add a new client name in column A, for example in A15."}

UNIQUE and COUNTA

The cleanest version in modern Excel.

=COUNTA(UNIQUE(A2:A100))How many different values.
=COUNTA(UNIQUE(FILTER(A2:A100, B2:B100="North")))Different clients in the North region.

SUMPRODUCT and COUNTIF (every version)

Each value contributes 1 divided by how often it appears, so a value that appears three times adds three thirds.

=SUMPRODUCT(1/COUNTIF(A2:A100, A2:A100))Distinct values; the range must have no empty cells.
=SUMPRODUCT((A2:A100<>"")/COUNTIF(A2:A100, A2:A100&""))The same, safe with blank cells.

A PivotTable

Tick Add this data to the Data Model when you create it, then choose Distinct Count in Value Field Settings.

Value Field Settings → Distinct CountDistinct values per group without formulas.

Common mistakes

#DIV/0! in the SUMPRODUCT version
The range includes empty cells. Use the blank-safe version.
Different spellings count separately
"Elm Studio" and "Elm Studio " are two values. Clean the data with TRIM.

Frequently asked questions

Is the count case-sensitive?

No. "elm studio" and "Elm Studio" count once.

How do I list the unique values instead?

Use =UNIQUE(A2:A100). See remove duplicates.

How do I count values that appear only once?

=COUNTA(UNIQUE(A2:A100, , TRUE)).

Practise it

UNIQUECOUNTIFSUMPRODUCTFILTER

Think you know this?

15 formula tasks, no hints, with a leaderboard. Absolute, relative and mixed references included.

Take the Pro Challenge →

More how-to guides

How to Round to the Nearest 5, 10 or 100 in Excel

Round numbers to the nearest 0.05, 5, 10, 100 or 1000 in Excel with ROUND, MROUND, CEILING and FLOOR. Live examples to try.

How to Find the Top 5 Values in Excel

Find the largest 3, 5 or 10 values in Excel with LARGE, and return the names next to them with INDEX and MATCH, XLOOKUP or SORT.

How to Check If a Cell Is Blank in Excel

Test whether a cell is empty in Excel with IF and an empty string or ISBLANK, and leave a result blank until the inputs are filled in.

How to Make a Running Total in Excel

Create a running total (cumulative sum) in Excel with SUM and a mixed reference, so each row shows the total so far. Live example.