Count in a Pivot Table: Count vs Distinct Count
By ExcelReady TeamUpdated 5 min read
The short answer
To count in a pivot table, drag a field into Values and set it to Count: right-click a number, choose Summarize Values By, then Count. Count adds up rows, so a customer with three orders counts three times. To count each customer once, tick Add this data to the Data Model when you create the pivot, then use Distinct Count.
Key takeaways
- Text fields in Values count automatically; number fields sum, so switch them with Summarize Values By > Count.
- Count counts non-empty cells, like COUNTA; Count Numbers counts only numbers, like COUNT.
- Distinct Count counts each value once, but only in pivots added to the Data Model.
- Count an ID column that is never blank, so every row is counted.
- COUNTIFS and COUNTA(UNIQUE(FILTER())) check pivot counts with formulas.
On this page+
A pivot table count tells you how many rows fall in each group: orders per region, tickets per agent, sales per month. You get it by putting a field in Values and setting it to Count. When you need to count each customer or product only once, you need Distinct Count instead. This guide shows both, explains why the two numbers differ, and how to check them with formulas.
How to count rows in a pivot table#
To count, put a field in the Values area and make sure it summarizes by Count. The examples use this order list in A1:D9:
| A | B | C | D | |
|---|---|---|---|---|
| 1 | Order | Customer | Region | Amount |
| 2 | 1001 | Acme | East | 4200 |
| 3 | 1002 | Birch | West | 1850 |
| 4 | 1003 | Acme | East | 3100 |
| 5 | 1004 | Cedar | South | 5600 |
| 6 | 1005 | Birch | West | 2400 |
| 7 | 1006 | Delta | East | 980 |
| 8 | 1007 | Acme | North | 1500 |
| 9 | 1008 | Cedar | South | 3300 |
- Click inside the data and choose Insert > PivotTable, then OK.
- Drag Region to Rows.
- Drag Customer to Values.
Because Customer is a text field, Excel uses Count by default. The pivot shows Count of Customer: East 3, North 1, South 2, West 2, Grand Total 8. That's the number of orders in each region. The beginner's guide to pivot tables covers the basic layout in more detail.
How to change Sum to Count#
Number fields go into Values as Sum. To count them instead:
- Right-click any number in the values area.
- Choose Summarize Values By > Count.
You can also click the field's drop-down arrow in the Values box, choose Value Field Settings, and pick Count on the Summarize Values By tab. While you're there, click Number Format to set how the values look.
Sometimes Excel picks Count for a number column on its own. That happens when the column has at least one blank cell or a number stored as text. If a sales column shows counts instead of totals, look for those cells first.
Count vs Count Numbers#
The Summarize list has two counting options, and they behave like two worksheet functions:
| Pivot option | Counts | Worksheet equivalent |
|---|---|---|
| Count | Every non-empty cell: numbers, text, dates | COUNTA |
| Count Numbers | Only cells holding numbers | COUNT |
Neither counts blank cells. So if you count a column where some cells are empty, those rows quietly drop out of the total. The safest field to count is one that is never empty, such as an order ID or ticket number. In the table above, counting Order gives the same 3, 1, 2, 2 as counting Customer, because no cell is blank.
How to use Distinct Count in a pivot table#
Count adds up rows, so Acme, with two East orders, counts twice. If the question is "how many different customers bought in each region?", use Distinct Count:
- Click inside the data and choose Insert > PivotTable.
- In the dialog, tick Add this data to the Data Model, then click OK.
- Drag Region to Rows and Customer to Values.
- Click the drop-down on Count of Customer in the Values box and choose Value Field Settings.
- Scroll to the bottom of the list, choose Distinct Count and click OK.
| Region | Count of Customer | Distinct Count of Customer |
|---|---|---|
| East | 3 | 2 |
| North | 1 | 1 |
| South | 2 | 1 |
| West | 2 | 1 |
| Grand Total | 8 | 4 |
Notice the Grand Total for Distinct Count is 4, not 2 + 1 + 1 + 1 = 5. Acme bought in East and North, but it's one customer overall. Distinct totals never simply add up, which is correct, but it surprises people.
Distinct Count only appears in pivots built on the Data Model, an option in Excel for Windows (2013 and later). You can't switch it on for an existing pivot; build a new one. If you don't see the checkbox, use the formula method below.
How to check a pivot table count with formulas#
Formulas give the same answers and are a good way to check a pivot. For the order count per region, use COUNTIF or COUNTIFS:
=COUNTIF(C2:C9,"East")The result is 3, the same as the pivot. For distinct customers in the East, combine three functions:
=COUNTA(UNIQUE(FILTER(B2:B9,C2:C9="East")))FILTER returns Acme, Acme, Delta. UNIQUE shortens that to Acme, Delta. COUNTA counts them: 2. UNIQUE and FILTER need Excel 2021, Excel 2024 or Microsoft 365. For when to use a table and when a pivot, read Excel table vs pivot table.
Why is my pivot table count wrong?#
Most wrong counts come from the data or a stale pivot. Check these:
- New rows are missing. A pivot doesn't update by itself. Right-click it and choose Refresh, and make sure the source range includes the new rows. See how to refresh a pivot table.
- The count is too low. The counted field has blank cells. Count an ID column instead.
- The count is too high. You need Distinct Count, not Count, because the same customer appears in many rows.
- "Banana" and "banana " count separately. A trailing space makes a different item. Clean the data with TRIM and refresh.
- The pivot won't build. A blank header causes the "PivotTable field name is not valid" error. Here is how to fix the field name error.
To show each count as a share of the total, right-click a value and choose Show Values As > % of Column Total.
Practise it#
Counting by group is one of the most common pivot questions in interviews and job tests. Practise pivot tables in a live spreadsheet: build a pivot, switch from Sum to Count and Average, and read the answers off it. For interview prep, go through the pivot table interview questions next.
Try it yourself
This is a live spreadsheet. Type the formula in the green cell and press Enter.
A pivot with Distinct Count would show how many different customers ordered in the East. Get the same answer with a formula: in G2, use COUNTA, UNIQUE and FILTER to count the distinct customers in B2:B9 where the region in C2:C9 is East.
| A | B | C | D | E | F | G | H | |
|---|---|---|---|---|---|---|---|---|
| 1 | Amount | |||||||
| 2 | East customers | |||||||
| 3 | ||||||||
| 4 | ||||||||
| 5 | ||||||||
| 6 | ||||||||
| 7 | ||||||||
| 8 | ||||||||
| 9 | ||||||||
| 10 | ||||||||
| 11 | ||||||||
| 12 |
Tip: Work from the inside out: FILTER the customers for East, UNIQUE removes repeats, COUNTA counts what is left.
Practise this in a lesson
Frequently asked questions
How do I count in a pivot table instead of sum?
Right-click any number in the values area, choose Summarize Values By and pick Count. You can also open Value Field Settings from the field's drop-down in the Values box.
How do I count unique values in a pivot table?
When you create the pivot, tick Add this data to the Data Model. Then open Value Field Settings for the field and choose Distinct Count. Existing pivots without the Data Model don't offer this option.
Why is my pivot table counting instead of summing?
The number column has at least one blank cell or a value stored as text, so Excel defaults to Count. Fix the data, then switch the field back to Sum with Summarize Values By.
What is the difference between Count and Count Numbers in a pivot table?
Count counts every non-empty cell, including text. Count Numbers counts only cells with numbers. They match COUNTA and COUNT in a worksheet.
Why doesn't Distinct Count appear in my pivot table?
The pivot wasn't created with the Data Model. Rebuild it from Insert > PivotTable with Add this data to the Data Model ticked. This option is in Excel for Windows; on other versions, use a formula instead.