Excel Formula To Count Unique Values

4 min read

Excel Formula to Count Unique Values

Counting unique values in Excel is a common task for data analysis, reporting, and dashboard creation. Whether you need to know how many distinct product IDs appear in a list, how many different names are present in a customer database, or simply want to eliminate duplicates before performing further calculations, the right formula can save time and reduce errors. On the flip side, this article explains several reliable methods, from the classic COUNTIF approach to the newer dynamic array functions available in modern versions of Excel. By the end, you will have a toolbox of formulas that you can apply directly to your worksheets Simple, but easy to overlook..

Understanding Unique Values

Before diving into formulas, it helps to define what “unique” means in this context. A unique value is any item that appears exactly once in a selected range, or it can refer to any distinct item regardless of frequency. And for most counting purposes, we want the number of different items, not the total occurrences. This distinction guides the choice of formula: some functions count distinct items, while others count items that appear only once Worth keeping that in mind..

Basic COUNTIF Approach

The most straightforward way to count unique values uses the COUNTIF function together with a helper column.

  1. Create a helper column that marks each cell as “duplicate” or “unique”.
  2. Use COUNTIF to count how many times each value appears.
  3. Sum the results where the count equals 1 (for truly unique) or simply count the distinct entries.

Example with a helper column:

A (Values) B (Helper)
Apple =COUNTIF($A$1:$A$100, A1)=1
Banana =COUNTIF($A$1:$A$100, A2)=1
Apple =COUNTIF($A$1:$A$100, A3)=1
… …

In B1, enter =COUNTIF($A$1:$A$100, A1)=1 and copy down. The helper column returns TRUE for values that appear only once and FALSE otherwise. To get the total count of unique items, use SUM:

=SUM(B1:B100)

Pros: Simple, works in all Excel versions.
Cons: Requires a helper column, not dynamic if the source data changes.

Using SUMPRODUCT for a One‑Formula Solution

If you prefer not to add a helper column, SUMPRODUCT can accomplish the same task in a single formula. The idea is to compare each cell with all other cells and count how many times the value is the smallest occurrence Less friction, more output..

=SUMPRODUCT(1/COUNTIF(A1:A100, A1:A100))

Explanation:

  • COUNTIF(A1:A100, A1:A100) returns an array of counts for each value (e.g., 2, 1, 2, …).
  • 1/COUNTIF(...) creates an array where each unique value contributes 1 and duplicates contribute fractions (e.g., 0.5, 1, 0.5).
  • SUMPRODUCT adds all those fractions, resulting in the total number of distinct values.

Note: This formula works well for moderate data sizes. Very large ranges may cause performance issues Less friction, more output..

Advanced Functions: COUNTIFS, FILTER, and UNIQUE

Modern Excel (Office 365, Excel 2021, and later) introduces dynamic array functions that simplify counting unique values, especially when you need to apply criteria Easy to understand, harder to ignore..

1. FILTER + COUNTA

The FILTER function extracts a subset of data based on a condition, and COUNTA counts non‑blank cells. Combine them to count unique values that meet specific criteria Most people skip this — try not to. Practical, not theoretical..

=COUNTA(UNIQUE(FILTER(A1:A100, B1:B100="East")))
  • FILTER(A1:A100, B1:B100="East") returns only the values from column A where column B equals “East”.
  • UNIQUE(...) removes duplicates from that filtered list.
  • COUNTA counts the remaining items, giving the number of unique entries for the “East” region.

2. UNIQUE + COUNTA (Simplest Form)

If you only need the total count of distinct values without any criteria:

=COUNTA(UNIQUE(A1:A100))

This single formula automatically handles duplicates and updates dynamically when the source range changes And it works..

3. COUNTIFS with UNIQUE

For criteria‑based counting, you can nest COUNTIFS inside UNIQUE or use SUMPRODUCT as shown earlier. An example using SUMPRODUCT:

=SUMPRODUCT(--(COUNTIF(A1:A100, A1:A100)=1), --(B1:B100="North"))

Here, the first part checks for values that appear exactly once, and the second part applies the “North” criterion It's one of those things that adds up..

Dynamic Array Formula (Office 365/2021)

The newest approach leverages the UNIQUE function directly, which spills the distinct values into adjacent cells. Pair it with COUNTA for an instant count Easy to understand, harder to ignore. Less friction, more output..

=COUNTA(UNIQUE(A1:A100))

Why this is powerful:

  • No helper columns or array‑entry keystrokes (Ctrl+Shift+Enter) required.
  • The result updates automatically as you add or remove data.
  • Works without friction with other dynamic functions like FILTER, SORT, and SORTBY.

Counting Unique Values with Criteria

Often you need to know how many distinct items exist only for a subset of data, such as unique product codes sold in a specific month. Below are two reliable patterns:

Using FILTER + UNIQUE

=COUNTA(UNIQUE(FILTER(A2:A1000, (B2:B1000="Jan")*(C2:C1000>=DATE(2024,1,1))*(C2:C1000<=DATE(2024,1,31)))))
  • Column A contains product IDs.
  • Column B indicates the month.
  • Column C holds the date.
  • The formula counts distinct product IDs sold in January 2024.

Using SUMPAPRODUCT with a Helper Array

=SUMPRODUCT(1/COUNTIFS
Fresh from the Desk

New Around Here

Neighboring Topics

Round It Out With These

Thank you for reading about Excel Formula To Count Unique Values. We hope the information has been useful. Feel free to contact us if you have any questions. See you next time — don't forget to bookmark!
⌂ Back to Home