Counting Unique Values in Excel — Complete Guide (2026)
Count unique values in Excel using UNIQUE, SUMPRODUCT, pivot tables, and Power Query. Six methods with formulas, examples, and when to use each.

Counting Unique Values in Excel — Complete Guide (2026)
Short answer: there is no COUNTUNIQUE function in Excel. That belongs to Google Sheets. People search for it because they assume parity between the two — but Microsoft never shipped it. What Excel gives you instead is six different routes to the same answer, and the right one depends on your Excel version and the size of your data.
If you're on Microsoft 365 or Excel 2021, the fastest route is =COUNTA(UNIQUE(A2:A100)). Two functions. Done. The UNIQUE function returns the distinct values as a dynamic spill, and COUNTA counts what came back. Clean, fast, readable a year later.
On older versions — 2019, 2016, anything before dynamic arrays — you fall back to =SUMPRODUCT(1/COUNTIF(A2:A100,A2:A100)). It works. It's elegant in a math-trick way. It also crawls on ranges over about 10,000 rows because Excel recomputes COUNTIF for every cell. Worth knowing before you copy it into a 50,000-row sheet and wait three minutes for a recalc.
The other four methods? Pivot tables with distinct count, Power Query group-by, advanced filter, and helper columns. Each one fits a specific situation. This guide walks all six with copy-paste formulas, screenshots in your head, and the gotchas nobody warns you about — blank cells, mixed text and numbers, case sensitivity, conditional counts. By the end you'll pick the right method in about ten seconds.
One quick reality check before we start: Excel's default behavior is case-insensitive. "Apple" and "apple" count as one value, not two. If you need case-sensitive counting — common in product SKUs or password lists — you need a different formula entirely. We cover that at the end. For everything else, the standard methods treat case as noise. Most people want that. A few don't.
If you came here looking for Excel basics first, brush up with our excel guide before jumping into formulas. Already comfortable with formulas? Pair this with countifs excel for conditional counting patterns. Both pages link back here for the unique-count step.

Excel has no COUNTUNIQUE function. If you've Googled "countunique excel" and landed on a Microsoft docs page that doesn't exist — that's why. COUNTUNIQUE is a Google Sheets function. Excel uses COUNTA(UNIQUE(...)) for the same result on Microsoft 365, and array formulas with SUMPRODUCT + COUNTIF on older versions. The confusion costs hours every week. Bookmark this page.
Excel Unique Count Methods at a Glance
The Six Methods — Side by Side
The modern answer. <code>=COUNTA(UNIQUE(A2:A100))</code>. UNIQUE returns distinct values as a dynamic spill; COUNTA counts them. Requires Microsoft 365 or Excel 2021. Fastest, cleanest, what you should use if you have it.
- Version: M365, 2021
- Speed: Instant
- Difficulty: Easiest
The classic array formula. <code>=SUMPRODUCT(1/COUNTIF(A2:A100,A2:A100))</code>. Works in every Excel version back to 2007. Math trick: each value's reciprocal-count sums to its unique presence. Slow on large ranges.
- Version: 2007+
- Speed: Slow at 10K+ rows
- Difficulty: Moderate
<code>=SUMPRODUCT((A2:A100<>"")/COUNTIF(A2:A100,A2:A100&""))</code>. Adds blank-cell protection. The plain SUMPRODUCT formula throws #DIV/0 when the range has empty cells. This one filters them out cleanly.
- Version: 2007+
- Use When: Range has blanks
- Difficulty: Moderate
Insert a pivot table, drag the field to Values, right-click → Summarize Values By → Distinct Count. No formula needed. The "Add this data to the Data Model" checkbox must be ticked when creating the pivot.
- Version: 2013+
- Speed: Fast on any size
- Difficulty: Easy
Data tab → Get Data → From Table/Range → Group By → Count Distinct Rows. Best for huge datasets and recurring workflows. Refreshable. Handles 1M+ rows without choking. Slight learning curve.
- Version: 2016+
- Speed: Fast at million+ rows
- Difficulty: Intermediate
Data tab → Advanced Filter → "Copy to another location" → tick "Unique records only". Outputs the distinct list to a new range. Then count with COUNTA. Old-school but reliable when formulas fail.
- Version: All versions
- Speed: Fast
- Difficulty: Easy
Method 1 in Depth: COUNTA + UNIQUE (The Modern Way)
If your Excel says Microsoft 365 or 2021 in the About box, you have UNIQUE. Test it: type =UNIQUE(A2:A10) in any blank cell and press Enter. If a list spills downward into the cells below — congrats, you have dynamic arrays. If you get #NAME? — you don't.
The full unique-count formula is two functions stacked: =COUNTA(UNIQUE(A2:A100)). UNIQUE pulls every distinct value from the range. COUNTA counts the non-empty cells in that spill. The whole thing recalculates instantly even on 50,000 rows because UNIQUE is implemented in compiled C++, not in the formula engine. That's the speed difference versus the SUMPRODUCT trick — UNIQUE runs in milliseconds where SUMPRODUCT takes seconds.
Variations Worth Knowing
Want the unique count excluding blanks? Wrap the range in a filter: =COUNTA(UNIQUE(FILTER(A2:A100,A2:A100<>""))). Three functions, still under 50 characters. FILTER strips empties before UNIQUE sees them.
Want unique values that appear only once (true singletons, not duplicates)? Pass UNIQUE a second argument: =COUNTA(UNIQUE(A2:A100,FALSE,TRUE)). The TRUE in the third position tells UNIQUE "only return values that appear exactly once." Useful for finding one-off entries in a log.
Multi-column unique combinations? UNIQUE handles arrays. =ROWS(UNIQUE(A2:B100)) counts distinct row pairs across columns A and B. Stop using helper columns — UNIQUE does it natively in one cell.
What Breaks
UNIQUE is case-insensitive by default. "USA" and "usa" collapse to one entry. If case matters, you need an EXACT-based approach (covered later). UNIQUE also treats "5" (text) and 5 (number) as different values — common gotcha when data comes from a CSV import. Run =VALUE(A2) conversion first if you suspect mixed types.
Modern Excel (M365/2021): =COUNTA(UNIQUE(A2:A100)) — done in two functions, runs in milliseconds, handles multi-column with =ROWS(UNIQUE(A2:B100)). Older Excel (2019 and back): =SUMPRODUCT(1/COUNTIF(A2:A100,A2:A100)) for clean ranges, append &"" on the COUNTIF arg if blanks exist. Both formulas are case-insensitive by default — that's usually what you want.
Method 2 in Depth: The SUMPRODUCT/COUNTIF Trick
This formula is older than dynamic arrays by about fifteen years. It still works in every Excel version. The logic: COUNTIF returns how many times each value appears. Divide 1 by that count, and each value contributes a fraction that sums to exactly 1 per unique value. SUMPRODUCT totals the array. Pure math elegance.
The formula: =SUMPRODUCT(1/COUNTIF(A2:A100,A2:A100)). Press Enter — not Ctrl+Shift+Enter. SUMPRODUCT handles arrays natively, so no array-formula braces needed. If you see {=SUMPRODUCT...} with curly braces, you accidentally pressed CSE; delete and re-enter with plain Enter.
Bookmark our excel formulas reference for more SUMPRODUCT patterns — it's the swiss army knife of older Excel.
The Empty-Cell Problem
If A2:A100 contains any blank cells, the formula returns #DIV/0!. Why? COUNTIF returns 0 for empties, and 1/0 is the divide-by-zero error. The fix: append &"" to coerce blanks into empty strings, then filter them out with a comparison.
Empty-safe formula: =SUMPRODUCT((A2:A100<>"")/COUNTIF(A2:A100,A2:A100&"")). The (A2:A100<>"") piece returns TRUE/FALSE (which Excel reads as 1/0), so blanks contribute zero to the sum. The &"" inside COUNTIF prevents the divide-by-zero error. Use this version whenever your data might have gaps.
How the Math Actually Works
People copy the SUMPRODUCT formula without understanding it. Here's the intuition. Imagine your column contains [Apple, Banana, Apple, Cherry, Apple]. COUNTIF returns [3, 1, 3, 1, 3] — how many times each value appears. Take the reciprocal: [1/3, 1/1, 1/3, 1/1, 1/3]. Sum that array: 1/3 + 1 + 1/3 + 1 + 1/3 = 3. Three unique values: Apple, Banana, Cherry. The three Apples each contribute 1/3, summing to one whole Apple. Banana and Cherry each contribute their full 1.
That trick — fractions that sum to 1 per unique value — is forty-year-old spreadsheet folklore. It predates Excel. Lotus 1-2-3 users had the same pattern. Worth knowing because the same logic applies to a dozen other counting problems: count unique on a filtered list, count unique with weights, count unique across sheets. Master the SUMPRODUCT-reciprocal pattern and you can adapt it to anything.

Pick Your Method — Decision Guide
Microsoft 365 / Excel 2021: Use Method 1 — =COUNTA(UNIQUE(range)). Don't even consider the other formulas. UNIQUE is faster, cleaner, and reads like English a year later.
Excel 2019: No UNIQUE function. Use Method 2 (SUMPRODUCT) for small ranges, Method 4 (pivot table) for anything over 5,000 rows.
Excel 2016 / 2013: Pivot table distinct count works (requires the Data Model checkbox). SUMPRODUCT formula works. Skip UNIQUE entirely.
Excel 2010 / 2007: SUMPRODUCT formula or Advanced Filter. Power Query is available as a free Microsoft add-in for 2010 and works well.
Method 3: Conditional Unique Counts (The Hard One)
Real-world question: how many unique customer IDs ordered from the West region in 2026? That's a conditional unique count. UNIQUE alone can't do it cleanly. SUMPRODUCT with COUNTIFS does.
The formula: =SUMPRODUCT((B2:B100="West")/COUNTIFS(A2:A100,A2:A100,B2:B100,B2:B100)). Assume column A is customer IDs, column B is region. The first piece filters rows where region equals "West." The COUNTIFS counts how many times each (ID, region) pair appears together. The reciprocal-sum math gives you unique IDs that ordered from West.
Add more criteria by extending COUNTIFS: =SUMPRODUCT((B2:B100="West")*(C2:C100=2026)/COUNTIFS(A2:A100,A2:A100,B2:B100,B2:B100,C2:C100,C2:C100)). Now it's unique customers from West in 2026. Slow on big data — but accurate.
The M365 Alternative
On Microsoft 365, FILTER + UNIQUE does the same job more readably: =COUNTA(UNIQUE(FILTER(A2:A100,(B2:B100="West")*(C2:C100=2026)))). Four functions but each one is obvious. FILTER pulls rows matching both criteria. UNIQUE deduplicates. COUNTA counts. Reads top-to-bottom like a sentence.
Why Conditional Counts Get Slow
Every COUNTIFS call inside SUMPRODUCT runs once per row. A 10,000-row range with two criteria means 100,000,000 internal comparisons. That's why your laptop fan kicks on. Excel doesn't cache intermediate results — each cell recomputes from scratch on every recalc. Toggle calculation to manual (Formulas tab → Calculation Options → Manual) while you build the sheet, then flip back to Automatic when done.
If you find yourself writing conditional unique counts on data over 50,000 rows weekly, switch to Power Query. Group By with multiple grouping columns gives you the same answer in a tenth of the time, and refreshes when source data updates. Formulas have a ceiling. Power Query does not.
Method 4 in Depth: Pivot Table Distinct Count
Pivot tables hid the Distinct Count option for years. It's there now but you have to know where to click. Here's the exact sequence:
Step one: select your data range. Step two: Insert tab → PivotTable. Step three — and this is the one most people miss — tick the checkbox "Add this data to the Data Model." Without that checkbox, you get the regular pivot and Distinct Count won't appear in the menu.
Step four: drag the field you want to count into the Values area. Step five: right-click the value in the pivot table → Summarize Values By → More Options → Distinct Count. Click OK. The pivot now shows distinct counts instead of regular counts.
This works on every Excel version from 2013 onward. The pivot table also gives you free grouping — if you want unique counts per region, drag region to Rows. Two clicks gives you a breakdown that would take ten minutes in formulas.
Why Some People Skip Pivots
The big complaint: pivot tables feel heavy for a single number. You're right — they are. But the Data Model overhead pays for itself the moment you need a second answer. Slice by month, by region, by category, all without rewriting a formula. Pivots scale better than people give them credit for.
When Pivots Beat Everything Else
The exception case: monthly reports where the data refreshes every cycle. Build a pivot once, save the workbook, refresh next month. The distinct count auto-updates. Try doing that with a formula — you'd manually adjust ranges every refresh. Pivots remember. Formulas don't.
The other case: shared workbooks. A pivot table is self-documenting. Anyone opening the file sees the structure. A SUMPRODUCT formula is a riddle. Three months later, even you won't remember why you wrote it that way.
Pivot Table Distinct Count — Step Sequence
- ✓Select your data range including headers — Ctrl+A inside the table works.
- ✓Insert tab → PivotTable → New Worksheet (default destination).
- ✓Tick the checkbox: Add this data to the Data Model. CRITICAL — Distinct Count won't appear without it.
- ✓Drag the field you want unique-counted into the Values box at the bottom right.
- ✓Right-click any number in the pivot → Summarize Values By → More Options.
- ✓Scroll to the bottom of the dialog → select Distinct Count → OK.
- ✓Optional: drag a grouping field (region, year, category) into the Rows box for per-group distinct counts.
- ✓Pivot refreshes automatically when source data changes — right-click → Refresh if needed.
Method 5 in Depth: Power Query for Big Data
Power Query is the answer when your data has 100,000 rows or you need the count to refresh on a schedule. It's built into Excel 2016 and later (called "Get & Transform" in the Data tab).
The workflow: Data tab → Get Data → From Table/Range. Excel opens the Power Query editor. Click the column header you want unique counts on. Transform tab → Group By. Choose "Count Distinct Rows." Click OK. Power Query returns a single-row table with the unique count. Close & Load back to Excel.
The magic: it's refreshable. Add 50,000 new rows tomorrow, right-click the loaded table → Refresh. The count updates. No formula to drag, no pivot table to rebuild.
The M Code Behind the Scenes
Every click in Power Query generates an M-language step. Open Advanced Editor to see what it built. A typical distinct count looks like: = Table.RowCount(Table.Distinct(Source, {"ColumnName"})). Two function calls. Cleaner than any Excel formula. You can edit M directly to add filters, joins, and conditional logic before counting.
For genuinely huge data — millions of rows from a SQL Server or SharePoint source — Power Query streams through the data instead of loading it all into memory. That's why it doesn't choke where pivot tables sometimes do. The trade-off is setup time. Once configured though, refresh is instant.
Method 6: Advanced Filter for Old Excel
Stuck on Excel 2010 or earlier? Advanced Filter still works and ships with every version back to Excel 95. Data tab → Sort & Filter group → Advanced. Pick "Copy to another location." Pick your list range as the source. Pick an empty cell as the destination. Tick "Unique records only." Click OK. Excel writes the deduplicated list to your destination cell, expanding downward. Then =COUNTA(destination_range) gives you the count.
It's two steps instead of one, but it's bulletproof. No formula to maintain. No Data Model to configure. No Microsoft 365 subscription required. The only downside: it's static. Add new data and you re-run the filter manually. For one-off counts it's perfectly fine.

Speed Benchmarks — Real Numbers
Case-Sensitive Unique Counts
Excel ignores case by default. "Apple" and "apple" count as one value with every standard method. If you need case-sensitive counting — common with SKUs, product codes, or password lists — wrap with EXACT.
Case-sensitive formula: =SUMPRODUCT((A2:A100<>"")/MMULT((EXACT(A2:A100,TRANSPOSE(A2:A100))*1),ROW(A2:A100)^0)). Yes, it's ugly. MMULT plus EXACT compares every value to every other value case-sensitively. The reciprocal math then gives you a true case-sensitive distinct count. On Microsoft 365, this works as a regular formula. On older versions, enter with Ctrl+Shift+Enter.
For most users this is overkill — but when you need it, nothing else works. Bookmark this formula separately. You'll need it once a year and forget it every time.
Common Mistakes That Inflate Your Count
Trailing spaces. "Apple" and "Apple " count as two unique values. TRIM the column first. Hidden characters from web pastes — Alt+0160 non-breaking spaces in particular. CLEAN strips them. Mixed text and numbers — "5" stored as text differs from 5 as a number. Multiply the column by 1 in a helper to coerce.
The bigger trap: regional formatting. A date like 03/04/2026 means March 4 in America and April 3 in Europe. If your data was typed in mixed locales, the same date string could be parsed two different ways, doubling your unique count. Always check formatting before trusting any unique count over 100.
When the Count Looks Wrong
You ran the formula. It returned 47. You expected 50. What now? First, run UNIQUE alone and eyeball the list. Three values short means three duplicates that look identical but aren't. Sort the original column and scan for near-duplicates — "john.smith@gmail.com" vs "John.Smith@gmail.com" (case difference), "ACME Corp" vs "ACME Corp " (trailing space), "USA" vs "U.S.A." (punctuation).
Second test: paste the column into Notepad++ with View → Show All Characters enabled. Tab characters, line breaks, and Alt+0160 spaces become visible. These cause silent duplicate-bloat. Clean the column, paste back, recount.
Third test: check data types. =ISNUMBER(A2) versus =ISTEXT(A2) on each row. Mixed types inflate unique counts because Excel sees them as different even when they display the same. The fix is column-wide: select column, Data tab → Text to Columns → Finish. That forces type conversion based on cell content.
If conditional logic is a weak spot for you, the countifs excel walkthrough covers multi-criteria patterns that pair perfectly with the conditional unique-count technique above. Need a quick keyboard productivity win first? The keyboard shortcut to delete row in excel guide saves a few seconds every time you clean data.
Formulas vs Pivot Tables vs Power Query
- +Live recalculation — count updates instantly when data changes
- +Inline in your worksheet — no separate output area needed
- +Easy to combine with other formulas (IF, FILTER, etc.)
- +Smaller file size — no Data Model overhead
- +Visible logic — anyone reading the sheet can audit the formula
- −Slow on 10,000+ rows (especially SUMPRODUCT)
- −Requires Microsoft 365 for the cleanest version (UNIQUE)
- −Conditional unique counts get ugly fast with formulas
- −Pivot tables and Power Query handle million-row datasets without choking
- −Power Query refreshes on a schedule — set it and forget it
Before You Count — Data Cleanup Checklist
- ✓Trim whitespace — "Apple " and "Apple" count as different values. Run TRIM on the column first.
- ✓Standardize case if needed — UPPER, LOWER, or PROPER, depending on what "unique" means for your data.
- ✓Convert text-numbers to real numbers — "5" (text) and 5 (number) are different. Use VALUE() or paste special multiply by 1.
- ✓Remove invisible characters — CLEAN() strips non-printable characters that come from CSV/web imports.
- ✓Handle blanks intentionally — decide if empty cells count as a value or get excluded, then pick the formula variant that matches.
- ✓Check for hidden duplicates with different spelling — "NYC" and "New York" won't match unless you normalize first.
- ✓Verify date formats — dates stored as text vs real dates produce different counts. Use DATEVALUE if needed.
- ✓Document your method in a comment — "Distinct count using COUNTA(UNIQUE) — M365 required" saves your future self twenty minutes.
Excel Questions and Answers
About the Author
Business Consultant & Professional Certification Advisor
Wharton School, University of PennsylvaniaKatherine Lee earned her MBA from the Wharton School at the University of Pennsylvania and holds CPA, PHR, and PMP certifications. With a background spanning corporate finance, human resources, and project management, she has coached professionals preparing for CPA, CMA, PHR/SPHR, PMP, and financial services licensing exams.