Sub topic 8
Choosing a summary function
This chapter covers how a value field summarises data. It assumes you can already create a PivotTable and drag fields into the Rows, Columns and Values areas. It also assumes you know what a flat source table is, such as the Date, Region, Product, Units and Sales dataset used in this tutorial.
What a summary function does
A value field takes many source rows that fall into one cell of the PivotTable and reduces them to a single number. The rule it uses for that reduction is the summary function. If East and Widget match two source rows, the summary function decides whether the cell shows their total, their count, their average or something else.
Excel picks the function for you when you drag a field into Values. The rule is simple:
- If every non-blank cell in the source column is a number, Excel uses Sum.
- If the column contains any text, or any cell is blank in a way Excel reads as text, Excel uses Count.
This default is the cause of many wrong results, so check it each time you add a value field.
The common functions
| Function | What it returns | Typical use |
|---|---|---|
| Sum | Total of the numbers | Sales, units, cost |
| Count | Number of non-empty cells, numbers and text | How many records exist |
| Average | Sum divided by the number of numeric cells | Typical order value |
| Max | Largest number | Best single sale |
| Min | Smallest number | Smallest single sale |
| Count Numbers | Number of cells that contain numbers only | Records with a valid numeric entry |
| Product | Result of multiplying the numbers | Compounding rates |
| StdDev, StdDevp, Var, Varp | Spread of the numbers | Statistical analysis |
Count and Count Numbers differ. Count includes text cells. Count Numbers ignores them. When you want to know how many records exist, Count is correct, and the field you count should be one that is never blank.
Changing the summary function
- Click any cell inside the field's values in the PivotTable.
- Right-click and choose Summarize Values By, then pick a function. For more choices, select Value Field Settings.
- Alternatively, in the Values area of the PivotTable Fields pane, click the field and choose Value Field Settings.
The Summarize Values By tab in the dialog box lists the functions. The Custom Name box lets you replace a label such as "Sum of Sales" with something clearer, such as "Total Sales". The new name cannot match an existing field name exactly, so add a trailing space or use different wording if Excel rejects it.
A worked example
Use the dataset below. Paste it into a worksheet, convert it to a Table if you like, and insert a PivotTable.
Date,Region,Product,Units,Sales
2025-01-05,East,Widget,10,250
2025-01-12,West,Gadget,4,180
2025-02-03,East,Gadget,7,315
2025-02-14,West,Widget,12,300
2025-03-09,East,Widget,5,125Set up the fields like this:
Rows: Region
Columns: Product
Values: Sum of SalesThe grid shows total sales for each region and product pair. East and Widget has two source rows (250 and 125), so the cell shows 375. West and Gadget has one row, so it shows 180.
Now change the same field to Average. East and Widget becomes 187.5, because 375 divided by 2 rows is 187.5. Change it to Count, and the cell shows 2. Change it to Max, and it shows 250. Each function answers a different question about the same set of rows.
Using the same field more than once
You can drag one field into Values several times. Each copy has its own summary function. This lets you show Sum of Sales, Average of Sales and Count of Sales side by side for each region.
Excel labels the copies "Sum of Sales", "Average of Sales" and so on. When two copies use the same function but different settings, Excel adds a suffix such as "2". Give each copy a clear Custom Name so readers can tell the columns apart.
When you have more than one value field, Excel adds a Values item to the Columns area. This item controls whether the value fields sit side by side as columns or stacked as rows. Drag it to Rows if you want them stacked.
Common errors
Text numbers cause Count instead of Sum
Suppose the Sales column holds numbers stored as text, perhaps after an import that left a leading apostrophe. Excel defaults to Count, and the PivotTable shows "Count of Sales". Switching to Sum will then return 0, because text is ignored.
To fix it:
- Correct the source column so every value is a true number. Use Data > Text to Columns and finish, or multiply the column by 1 with Paste Special.
- Refresh the PivotTable.
- Reset the function to Sum.
A single blank cell changes the default
If one cell in the Sales column is empty, Excel still treats the column as numeric when you drag the field in, so Sum is used. If one cell contains a space or text, the default becomes Count. A column that looks numeric may therefore behave differently after a small data-entry error. Look at the label in the Values area each time.
Average of averages
Average divides the sum by the number of source rows in the cell. At a subtotal or grand total, it recalculates across all underlying rows. It does not average the visible cell averages. This is usually what you want. A mean of the visible numbers, which would weight each cell equally, will be different if cells have different row counts.
For example, East and Widget has two rows averaging 187.5. East and Gadget has one row at 315. The East subtotal average is (250 + 125 + 315) / 3 = 230, not (187.5 + 315) / 2 = 251.25.
Counting distinct items
Count counts rows, not unique values. If Region appears 5 times, Count of Region returns 5, not 2. To count unique values you need to add the data to the Data Model and use Distinct Count. That option appears in the function list only when the PivotTable was created with "Add this data to the Data Model" ticked.
Choosing the right function
Use these questions to decide.
- Do you need a total? Use Sum.
- Do you need to know how many records there are? Use Count on a field that is always filled in.
- Do you need a typical value? Use Average, and check how many rows sit behind each cell.
- Do you need an extreme value? Use Max or Min.
- Do you need the number of unique entries? Use Distinct Count through the Data Model.
A ratio such as average price is a special case. Average of a Price column is only correct when each row has the same weight. If rows represent different quantities, divide total Sales by total Units instead. This is done with a calculated field, covered in a later chapter.
Checking your result
A quick check protects you from silent mistakes. Compare the PivotTable Grand Total to a direct formula on the source, such as =SUM(Sales) on the Sales column. For the sample dataset the total is 1170. If the two numbers differ, the field is probably set to Count, or the source includes text values.
Exercise
Using the sample dataset, the Sales column was imported as text, so the PivotTable shows "Count of Sales" with a value of 2 for East and Widget. Switching to Sum shows 0. What two steps fix this, and what value should the cell show afterwards?
Show answer
First convert the Sales column to true numbers (for example with Text to Columns, or Paste Special with Multiply by 1), then refresh the PivotTable and set the value field to Sum. The East and Widget cell should then show 375, the sum of 250 and 125.
Exercise
East has three source rows with sales of 250, 125 and 315. Which summary function gives 230 for the East subtotal, and why is that different from averaging the Widget and Gadget cell averages?
Show answer
Average gives 230, because it divides the total of 690 by 3 rows. Averaging the cell averages (187.5 for Widget and 315 for Gadget) gives 251.25, which weights each cell equally even though Widget has two rows and Gadget has one.