Sub topic 8
Choosing a summary function
This chapter assumes you can already create a PivotTable and drag fields into the Rows, Columns and Values areas of the PivotTable Fields pane. It uses the sales data from earlier chapters: Date, Region, Product, Units and Sales.
What a summary function does
A summary function decides how Excel combines the many source rows that fall into one cell of the PivotTable. With Region in Rows and Product in Columns, the East/Widget cell holds two source rows. The function says whether to add them, count them, average them, or pick one.
The common functions
| Function | Result | Typical use |
|---|---|---|
| Sum | Adds the values | Sales, units |
| Count | Counts non-empty cells | How many records exist |
| Average | Mean of the values | Typical order size |
| Max | Largest value | Biggest single sale |
| Min | Smallest value | Smallest single sale |
Excel picks a default for you. If a field contains only numbers, it uses Sum. If it contains any text or blank cells, it uses Count. This default is the cause of many wrong results, so always check the label on the value field.
Changing the function
- In the Values area, click the field and choose Value Field Settings. You can also right-click a number in the PivotTable and choose Summarize Values By.
- On the Summarize Values By tab, pick the function.
- Optionally edit Custom Name, for example "Average Sale". The name must differ from the source field name.
- Click OK.
With Rows: Region, Columns: Product and Values: Sum of Sales, you get total sales per cell. Changing the function to Average gives the mean sale per source row. East/Widget goes from 375 (250 + 125) to 187.5.
Using one field twice
You can drag the same field into Values more than once, and each copy can use its own function. Add Sales three times and set them to Sum, Average and Max. The result shows total, typical and peak sales side by side. Rename each one so the headings stay clear.
Common mistakes
- Count where you wanted Sum. A numeric column with a blank cell or a number stored as text defaults to Count. Fix the data, then switch the function back to Sum.
- Average of averages. An Average in a Grand Total row is the average of all source rows, not the average of the subtotals. Use that figure with care.
- Count versus Distinct Count. Count includes repeated values. Distinct Count needs the data added to the Data Model, which is a separate option.
Exercise
A PivotTable shows "Count of Units" with the value 2 for East/Widget. You want the total units sold. What do you do, and what number do you expect with the sample data?
Show answer
Open Value Field Settings for the field and choose Sum. The East/Widget rows contain 10 and 5 units, so you expect 15. If the field keeps defaulting to Count, check the Units column for blanks or numbers stored as text.