To get a distinct count in a pivot table, create the pivot table with Add this data to the Data Model ticked, drag the field into Values, then open Value Field Settings and choose Distinct Count at the bottom of the list. If you cannot use the Data Model, add a helper column to the source data that flags the first occurrence of each value, and sum that column in the pivot table instead.
A normal pivot table can only count a field, which counts every row, duplicates included. A distinct count (also called a unique count) counts each value once. The steps below follow Microsoft's documentation and Exceljet's walkthrough for Excel on Windows. Labels can differ in Excel for the web and Excel on Mac, so check the menus in your version.
The example data used below
Suppose a small order list has three columns and six rows. Customer Acme orders in both regions.
Region | Customer | Order
East | Acme | 1001
East | Acme | 1002
East | Birch | 1003
West | Acme | 1004
West | Cobalt | 1005
West | Cobalt | 1006
A plain count of Customer by region gives 3 for East and 3 for West, because it counts rows. The number you probably want is how many different customers bought in each region: 2 for East (Acme, Birch) and 2 for West (Acme, Cobalt).
How to get a distinct count in a pivot table (Data Model method)
Microsoft describes the Distinct Count summary function as "the number of unique values" and says it only works when you use the Data Model in Excel. The Data Model has to be switched on when the pivot table is created.
- Click any cell in your data and go to Insert > PivotTable.
- In the dialog, tick Add this data to the Data Model.
- Choose New Worksheet or Existing Worksheet and select OK.
- Drag
Regioninto Rows. - Drag
Customerinto Values. Excel will show it as a count of the field. - Click the arrow next to the field in the Values area and select Value Field Settings. You can also right-click a value in the pivot table and choose Summarize Values By > More Options.
- On the Summarize Values By tab, scroll to the end of the list and select Distinct Count. It is the last item.
- Optionally, edit Custom Name to something clearer, such as
Unique customers, and select OK.
Example output (worked out from the six rows above, not captured from a screen):
Row Labels Unique customers
East 2
West 2
Grand Total 3
Notice the Grand Total is 3, not 4. Acme is one customer who appears under both regions, and the total counts the three different customers across the whole data set once each. That is usually what a distinct count should do, but it means the rows no longer add up to the total. If a reader expects them to, tell them why.
Why Distinct Count is missing from the list
The most common reason is that the pivot table was created without the Data Model. A Microsoft Q&A answer puts it directly: the Distinct Count function is only available if the Data Model is behind the pivot table. Without it, the list of summary functions ends at the usual choices such as Sum, Count, Average, Max and Min.
Exceljet adds that the Data Model option can only be enabled when you create the pivot table. So you cannot go back and flip a switch on an existing one. Build a new pivot table from the same source with the box ticked. Your old pivot table is unaffected, and you can delete it once the new one works.
If the Add this data to the Data Model checkbox itself is not in your dialog, your version or edition of Excel may not include it. Exceljet says distinct count is available from Excel 2013 onward. The workaround in the next section does not need the Data Model at all.
How to get a distinct count without the Data Model
This method uses a helper column in the source data. Each row gets a 1 if it is the first time that value appears, and 0 otherwise. A pivot table can then add up the 1s with an ordinary Sum. This is plain formula logic you can check by hand, not a documented Excel feature, so test it on a few rows.
For a distinct count of customers overall, put this in a new column header such as FirstCustomer, in row 2 (the first data row), assuming Customer is in column B:
=IF(COUNTIF($B$2:B2, B2)=1, 1, 0)
The range starts fixed at $B$2 and grows as you fill the formula down. COUNTIF returns 1 only on the first row where that customer appears. Sum FirstCustomer in the pivot table and you get the number of different customers.
For a distinct count of customers within each region, with Region in column A, match both columns:
=IF(COUNTIFS($A$2:A2, A2, $B$2:B2, B2)=1, 1, 0)
Put Region in Rows and the new column in Values with Sum. Using the example data, East sums to 2 and West sums to 2.
There are two differences from the Data Model method:
- The Grand Total of the per-region helper column is the sum of the rows, so with the example data it shows 4, not 3. Acme is counted once in each region. Use the single-column formula if you need the overall unique number.
- The helper column does not respond to filters or slicers the way a real distinct count does. A customer whose first row is filtered out contributes nothing, even if later rows are still visible.
Convert the source to an Excel table first, as described in how to set up a pivot table in Excel, so the formula fills down automatically when you add rows. After adding data, refresh the pivot table.
Other ways to get the number you need
If you only need the total number of unique values in one column and not a pivot table, you do not have to build one. On a copy of the column, you can strip the repeats and count what remains, as covered in how to remove duplicates in an Excel column. In Excel 2021, Excel 2024 and Microsoft 365, the UNIQUE function returns the distinct values, and wrapping it in COUNTA gives the count:
=COUNTA(UNIQUE(B2:B7))
With the example column that returns 3. This gives one number for one column. It does not give a breakdown by region the way the pivot table does.
Check the result
A distinct count is easy to get subtly wrong, so verify it against a small slice you can count by eye. Filter the source to one region, read down the customer column and count the different names. That number should match the pivot table. Watch for two causes of a mismatch:
- Hidden differences.
AcmeandAcmewith a trailing space are two different values. Clean the source column before counting. - Case and spelling.
AcmeandACMEmay be treated as one value or two depending on the method. Compare on a sample rather than assuming.
Once the numbers agree, rename the field so the heading says what it measures. A column titled "Count of Customer" is easy to misread, while "Unique customers" is not.
Frequently asked questions
- Why is Distinct Count missing from my pivot table?
- Distinct Count only appears when the pivot table is built on the Excel Data Model. Microsoft's documentation says the function only works when you use the Data Model. If you created the pivot table without ticking Add this data to the Data Model, the option is not offered, and you need to create a new pivot table with the box ticked.
- Can I add Distinct Count to a pivot table I already made?
- Not by changing a setting on it. Exceljet states the Data Model option can only be enabled when you create the pivot table. Make a new pivot table from the same data with Add this data to the Data Model ticked, or use a helper column in the source data and keep the existing pivot table.
- Does Distinct Count work in older versions of Excel?
- Exceljet says the distinct count option is available in Excel 2013 and later. Menu names and the exact layout of the dialogs differ between versions and between Windows, Mac and Excel for the web, so check the options in your own copy.
- Does Distinct Count count blank cells?
- Test it on your own data before relying on it. This article does not cite a source on how blanks are treated, so the safest approach is to remove or fill blank cells in the source column first and compare the result against a count you can verify by hand.