Key points
- Distinct Count appears in Value Field Settings only when the PivotTable is built on the Data Model; Microsoft documents it for Excel for Windows (Microsoft 365, 2024, 2021, 2019 and 2016), and its summary list for Excel for the web does not include it.
- A PivotTable’s Count works like COUNTA: it counts non-empty records, so one employee with three training records counts as three.
- Distinct counts do not add up: in the sample log, 3 employees in October plus 4 in November is 7, but only 5 different employees trained.
- Without the Data Model, =COUNTA(UNIQUE(range)) gives a distinct count in Microsoft 365, Excel 2024 and 2021 (Windows and Mac) and Excel for the web; a blank cell in the range adds one unless you filter blanks out.
- On a Data Model PivotTable, Excel greys out the classic Calculated Field and Calculated Item commands; DAX measures, which Microsoft offers as another way to calculate, take their place.
To make a pivot table count unique values in Excel, tick Add this data to the Data Model when you insert the PivotTable, then change the value field from Count to Distinct Count. A normal PivotTable has no Distinct Count option, so it counts records: an employee with three training records counts three times. Below is a worked example you can rebuild in a few minutes, the reasons Distinct Count goes missing, and formulas that do the same job in Excel for Mac, Excel for the web and older versions.
Pivot table count unique values with the Data Model
Example (hypothetical): a compliance team logs every completed course and wants the number of different employees trained each month, not the number of completions. To follow along, type it into a blank sheet starting at cell A1 with the headers Date, Employee ID, Course and Month; the letters in brackets only show which column each one goes in, and column D is a formula added in step 1.
| Date (A) | Employee ID (B) | Course (C) | Month (D) |
|---|---|---|---|
| 10/5/2026 | E101 | Harassment prevention | 2026-10 |
| 10/5/2026 | E102 | Harassment prevention | 2026-10 |
| 10/12/2026 | E101 | Data privacy | 2026-10 |
| 10/19/2026 | E103 | Data privacy | 2026-10 |
| 10/26/2026 | E102 | Data privacy | 2026-10 |
| 11/2/2026 | E101 | Anti-bribery | 2026-11 |
| 11/9/2026 | E104 | Harassment prevention | 2026-11 |
| 11/9/2026 | E104 | Data privacy | 2026-11 |
| 11/16/2026 | E105 | Anti-bribery | 2026-11 |
| 11/23/2026 | E102 | Anti-bribery | 2026-11 |
The log has 10 records for 5 different employees: 5 records and 3 employees in October, 5 records and 4 employees in November.
Step 1: Make the data a table and add a Month column
Click any cell in the data and press Ctrl+T (Insert > Table), keeping My table has headers ticked. In D2 enter =TEXT(A2,"yyyy-mm"); inside a table, Excel fills the formula down the column. A table also picks up new rows when you refresh the PivotTable, which Microsoft recommends for PivotTable sources.
Step 2: Insert the PivotTable and add it to the Data Model
- Select a cell in the table and choose Insert > PivotTable.
- Choose New Worksheet.
- Tick Add this data to the Data Model, then select OK.
Without this check box, Distinct Count does not appear later. If an older report was built without it, the simplest fix is to insert a new PivotTable from the same table with the box ticked.
Step 3: Change Count to Distinct Count
Drag Month to Rows and Employee ID to Values. Because the IDs are text, Excel shows Count of Employee ID: 5, 5 and 10. Right-click any of those numbers, choose Value Field Settings, open the Summarize Values By tab, select Distinct Count and select OK. Microsoft’s summary function reference describes it as “The number of unique values” and notes that it “only works when you use the Data Model in Excel.” You can also reach the dialog from the PivotTable Analyze tab (Analyze in some older versions): Active Field > Field Settings.
| Month | Count of Employee ID | Distinct Count of Employee ID |
|---|---|---|
| 2026-10 | 5 | 3 |
| 2026-11 | 5 | 4 |
| Grand Total | 10 | 5 |
Can you group dates by month instead of using a helper column?
Yes. In a normal PivotTable, right-click a date, choose Group and pick Months (and Years if the data spans more than one year), as shown in Microsoft’s guide to grouping PivotTable data. In a Data Model PivotTable, dragging the Date field to Rows can make Excel add Date (Year), Date (Quarter) and Date (Month) fields automatically, a feature Microsoft introduced in Excel 2016. The helper column is used here because the same 2026-10 label then works in the PivotTable and in the formulas further down.
Pivot table distinct count vs Count: why the totals don’t add up
Count and Distinct Count answer different questions. Microsoft’s PivotTable calculation guide says the Count summary “works the same as the COUNTA function”: it counts every non-empty entry, so it tells you how many courses were completed. Distinct Count tells you how many different people completed them.
Distinct counts are not additive. October’s 3 employees plus November’s 4 makes 7, yet the grand total is 5, because E101 and E102 trained in both months. Microsoft’s DISTINCTCOUNT reference explains the same behavior: each value is counted once at every level of the report. Do not replace the grand total with a sum of the rows. If someone asks for 7, they are asking for “employee-months”, which is a different measure and should be labeled as one.
Blank and inconsistent IDs
Distinct Count in a Data Model PivotTable is an implicit measure built on DISTINCTCOUNT, and Microsoft’s DAX reference says DISTINCTCOUNT counts the BLANK value. A record with no employee ID therefore adds one to its month’s count (and appears as a (blank) item if you put Employee ID in Rows). Fill in or remove those records, or create an explicit measure that skips blanks: choose Power Pivot > Calculations > Measures > New Measure, enabling the Power Pivot add-in first if the tab is missing (Microsoft’s measure instructions) and enter =DISTINCTCOUNTNOBLANK(Table1[Employee ID]), using your table’s name from the Table Design tab. Select Check Formula before OK; if your Excel version does not recognize the function, it will say so.
Distinct Count compares the stored values, not what you meant to type. An ID entered as E101 in one row and E-101 in another counts as two people, so clean the ID column before you trust the number.
Why is Distinct Count missing from Value Field Settings?
If Distinct Count is not in the Summarize Values By list, check these causes in order:
- The PivotTable is not on the Data Model. Insert a new PivotTable with Add this data to the Data Model ticked.
- You are in Excel for the web. Microsoft’s list of summary functions for PivotTables in Excel for the web runs from Sum to Varp and does not include Distinct Count.
- You are in Excel for Mac. Microsoft’s Distinct Count, Data Model and Power Pivot pages do not list Excel for Mac, and the Add this data to the Data Model step appears only in its Windows instructions for creating a PivotTable.
- The source is an OLAP cube. Microsoft says you cannot change the summary function for fields from OLAP source data; the calculations are set on the server.
| Excel version (as Microsoft documents it, November 2026) | Distinct Count in a PivotTable | UNIQUE function | Best route |
|---|---|---|---|
| Excel for Microsoft 365, Excel 2024, Excel 2021 (Windows) | Yes, with the Data Model | Yes | Either |
| Excel 2019, Excel 2016 (Windows) | Yes, with the Data Model | Not listed | PivotTable, or the legacy formula below |
| Excel for Microsoft 365 for Mac, Excel 2024 for Mac, Excel 2021 for Mac | Not listed by Microsoft | Yes | UNIQUE formula or helper column |
| Excel for the web | Not in Microsoft’s summary function list for the web | Yes | UNIQUE formula or helper column |
Calculated Field greyed out after you add the Data Model
The trade-off: on a Data Model PivotTable, Excel greys out Fields, Items, & Sets > Calculated Field and Calculated Item. Microsoft’s calculation guide does not name the Data Model here; it says formulas cannot be created in PivotTables connected to OLAP data, and it offers measures in Power Pivot, written in the DAX formula language, as another way to calculate. If an existing report depends on calculated fields, rebuild them as measures before you switch, or keep the normal PivotTable and use the helper column method below. The recorded Excel Power Pivot data modeling webinar covers table relationships, DAX basics and measures such as year to date.
Count unique values in Excel with a formula
Formulas give a distinct count outside a PivotTable and work where the Data Model does not. All results below use the sample data in A1:D11.
Count unique values in a column with COUNTA and UNIQUE
=COUNTA(UNIQUE(B2:B11)) returns 5. UNIQUE returns the list of distinct IDs and COUNTA counts them. Microsoft lists UNIQUE for Excel for Microsoft 365 (Windows and Mac), Excel 2024, Excel 2021 (Windows and Mac) and Excel for the web, but not Excel 2019 or 2016.
A blank cell in the range adds one to that result, because UNIQUE returns the blank as one more item. If the column can contain blanks, use =IFERROR(ROWS(UNIQUE(FILTER(B2:B11,B2:B11<>""))),0), which also returns 5 here. FILTER drops the empty cells; if nothing is left, FILTER returns #CALC!, which COUNTA would count as 1, so ROWS with IFERROR returns 0 instead.
Distinct count with criteria: one month or one course
Add the condition inside FILTER. =COUNTA(UNIQUE(FILTER(B2:B11,D2:D11="2026-10"))) returns 3, and the same formula with "2026-11" returns 4. To count employees who completed Data privacy, use =COUNTA(UNIQUE(FILTER(B2:B11,C2:C11="Data privacy"))), which returns 4. If a month or course has no records, these formulas return 1, not 0, because COUNTA counts the #CALC! error; use the IFERROR(ROWS(UNIQUE(FILTER(…))),0) form above when that can happen.
One formula for every month: GROUPBY
In Excel for Microsoft 365, GROUPBY builds the whole summary in one formula. Its function argument accepts a LAMBDA, so =GROUPBY(D2:D11,B2:B11,LAMBDA(x,ROWS(UNIQUE(x))),0,0) spills two rows: 2026-10 with 3 and 2026-11 with 4. The fourth argument (0) says the ranges have no headers and the fifth (0) turns off totals, which avoids any confusion with the non-additive grand total. Microsoft lists GROUPBY for Excel for Microsoft 365 only.
Excel 2019 and 2016: the legacy array formula
Without UNIQUE, use the IF, SUM, FREQUENCY, MATCH and LEN combination from Microsoft’s count unique values among duplicates article:
=SUM(IF(FREQUENCY(IF(LEN(B2:B11)>0,MATCH(B2:B11,B2:B11,0),""),IF(LEN(B2:B11)>0,MATCH(B2:B11,B2:B11,0),""))>0,1))
It returns 5. In versions without dynamic arrays, confirm it with Ctrl+Shift+Enter so Excel adds the curly brackets. MATCH gives each ID the position of its first appearance (1, 2, 1, 4, 2, 1, 7, 7, 9, 2), FREQUENCY counts each first position once and returns zero for repeats, LEN keeps blank cells out, and SUM(IF(…>0,1)) counts the positions that remain.
Excel pivot count unique without the Data Model
In Excel for Mac or Excel for the web, a helper column lets a normal PivotTable produce the same monthly numbers. In E1 type First in month, in E2 enter =IF(COUNTIFS(B$2:B2,B2,D$2:D2,D2)=1,1,0) and fill down. Each row gets 1 the first time an employee appears in a month and 0 after that: 1, 1, 0, 1, 0, 1, 1, 0, 1, 1.
Build a normal PivotTable with Month in Rows and Sum of First in month in Values. It shows 3 for 2026-10 and 4 for 2026-11, but its grand total is 7, not 5, because the flag marks the first record per employee per month. The helper column is only right for the grouping it was built for: if you filter or slice by course, or need a different breakdown, build a flag that includes that column, and take the overall total from COUNTA(UNIQUE()).
Which unique count method should you use?

| Method | Where it works | Sample result | Watch for |
|---|---|---|---|
| Data Model PivotTable, Distinct Count | Excel for Windows | 3, 4, total 5 | No classic calculated fields; blank IDs count as one |
| =COUNTA(UNIQUE(range)) | Microsoft 365, 2024, 2021 (Windows and Mac), web | 5 | Blank cells add one; use the FILTER version |
| FILTER inside UNIQUE for criteria | Same as UNIQUE | 3 (October), 4 (Data privacy) | Exact text match on the criterion |
| GROUPBY with LAMBDA | Microsoft 365 | 3 and 4 | Not in perpetual versions |
| Helper column in a normal PivotTable | All versions, including Mac and web | 3, 4, total 7 | Grand total and other breakdowns are wrong |
| Legacy FREQUENCY array formula | All versions | 5 | Ctrl+Shift+Enter in older Excel |
For a one-off list rather than a live count, the same Microsoft article describes Data > Advanced with Unique records only to copy the distinct values elsewhere, then ROWS to count them. The copy does not update when the log changes.
If the IDs come from a separate HR roster, match them first with a lookup; XLOOKUP vs VLOOKUP explains which function to use. And if the count goes into an audit file, the log behind it matters as much as the formula.
What to do now
- Check your Excel version (File > Account > About Excel on Windows) against the version table above.
- Turn the source data into an Excel table and clean the ID column: no blanks, one spelling per person.
- On Windows, insert a new PivotTable with Add this data to the Data Model ticked and switch the ID field to Distinct Count.
- Check the result against =COUNTA(UNIQUE()) on the same column, and never sum distinct counts to get a total.
- Before you switch an existing report to the Data Model, list its calculated fields and plan the DAX measures that will replace them.
- On Mac or the web, use the UNIQUE formulas or the helper column and label what the grand total means.
More Excel sessions are listed under Software webinars, and new live dates appear in the 247Compliance newsletter.
Frequently asked questions
How do I count unique values in an Excel pivot table?
In Excel for Windows, insert the PivotTable with Add this data to the Data Model ticked, put the field to count in Values, then open Value Field Settings and choose Distinct Count on the Summarize Values By tab. A PivotTable created without the Data Model does not offer Distinct Count, so insert a new one with the box ticked.
Why is Distinct Count not showing in my pivot table?
The usual reason is that the PivotTable was created without Add this data to the Data Model. Microsoft’s list of PivotTable summary functions for Excel for the web does not include Distinct Count, and its Data Model pages do not list Excel for Mac, so on a Mac or the web use COUNTA with UNIQUE or a helper column. Fields from an OLAP cube also do not let you change the summary function.
Why doesn’t the distinct count grand total equal the sum of the rows?
Because a person who appears in more than one row is counted once in each row but only once in the total. Microsoft’s DAX documentation describes distinct count totals as not additive. If you need the sum of the rows, label it as a different measure, such as employee-months.
How do I count unique values in Excel without a pivot table?
Use =COUNTA(UNIQUE(range)) in Excel for Microsoft 365, Excel 2024, Excel 2021 or Excel for the web; if the range can contain blanks, filter them out first with FILTER, because a blank adds one to the result. In Excel 2019 or 2016, which do not have UNIQUE, use Microsoft’s SUM, IF, FREQUENCY, MATCH and LEN array formula, confirmed with Ctrl+Shift+Enter.
Does pivot table Distinct Count include blank cells?
Yes. Distinct Count in a Data Model PivotTable uses DISTINCTCOUNT, which Microsoft’s DAX reference says counts the BLANK value, so a missing ID adds one to the count. Fix the source records, or create a measure with DISTINCTCOUNTNOBLANK if your Excel version accepts it.
Can I add a calculated field to a Data Model pivot table?
Not with the classic Calculated Field command, which Excel greys out on Data Model PivotTables. Use a measure written in DAX instead, created from Power Pivot > Calculations > Measures > New Measure (enable the Power Pivot add-in if the tab is missing). If you need classic calculated fields, keep a normal PivotTable and use a helper column or formula for the unique count.
Build PivotTable reports that answer at a glance
Excel MVP David Benaim’s live webinar on Wednesday, December 16, 2026 (10:00 AM PT) shows how to aggregate data with PivotTables and the GROUPBY function, add slicers and timelines, and pick the right chart for each question.
See the Excel dashboards webinarSources (19)
- Microsoft Support: Change the summary function or custom calculation for a field in a PivotTable (Distinct Count, Data Model requirement, OLAP restriction)
- Microsoft Support: Create a PivotTable to analyze worksheet data (Windows, web and Mac instructions; Add this data to the Data Model)
- Microsoft Support: Calculate values in a PivotTable (Count works like COUNTA; summary functions for Excel for the web; OLAP limits on formulas; calculated fields)
- Microsoft Support: Group or ungroup data in a PivotTable
- Microsoft Support: Create a Data Model in Excel (Applies To list)
- Microsoft Support: Power Pivot - overview and learning (the old “Where is Power Pivot?” link now redirects here; Applies To list; enabling the add-in)
- Microsoft Support: Measures in Power Pivot (implicit measures: SUM, COUNT, MIN, MAX, DISTINCTCOUNT, AVG)
- Microsoft Support: Create a Measure in Power Pivot (Measures > New Measure, Check Formula)
- Microsoft Learn: DISTINCTCOUNT function (DAX) (counts BLANK; totals not additive)
- Microsoft Learn: DISTINCTCOUNTNOBLANK function (DAX)
- Microsoft Support: UNIQUE function (syntax and Applies To list)
- Microsoft Support: FILTER function (#CALC! when no results, if_empty argument)
- Microsoft Support: COUNTA function (counts error values and empty text)
- Microsoft Support: ROWS function
- Microsoft Support: GROUPBY function (function argument accepts a lambda; Applies To Excel for Microsoft 365)
- Microsoft Support: Count unique values among duplicates (IF, SUM, FREQUENCY, MATCH, LEN; Advanced Filter Unique records only)
- Microsoft 365 blog: Time grouping enhancements in Excel 2016 (October 13, 2015)
- 247Compliance: Interactive dashboards & analytics in Excel (live webinar, December 16, 2026)
- 247Compliance: Data Modelling and Analysis with Excel Power Pivot (recorded webinar)
This article is general information, not legal or tax advice. Check the official sources above or consult a qualified advisor for your situation.
How we research, check and correct articles: editorial policy. Spotted an error? Tell us.
LIVE WEBINAR · 10 DEC · 10:00 AM PT · 1:00 PM ET
Enhancing Pivot Tables with Images: Visualize Your Data Like a Pro
Abdelrahman Abdou · 60 min · from $179
Enroll


