Add a calculated field and use PivotTable figures in formulas
More from PivotTables8 minPremium
Builds on Count, average and show percentages in a PivotTable and Total by several conditions with SUMIFS.
The controller of a furniture maker in Charlotte reviews each product line's profit and margin every month. The order list has revenue and cost but no profit column, and the one-page summary for the owners needs a few PivotTable figures in formulas of its own.
How it works
A calculated field is a field the PivotTable works out from other fields. Click a cell in the PivotTable and choose PivotTable Analyze > Fields, Items, & Sets > Calculated Field. Type a name, such as Profit, and a formula, such as =Revenue-, then click Add and OK. The field goes into Values and joins the field list.
A calculated field works on the sums. For each product line it takes the sum of Revenue minus the sum of Cost, so a ratio such as Profit divided by Revenue gives the margin on the line's total revenue, where a big order counts for more than a small one.
To use a PivotTable figure in a formula outside it, type = and click the figure. Excel writes a GETPIVOTDATA formula, such as GETPIVOTDATA(, which finds the value by its field and item names instead of its address. It keeps returning the Tables profit after the PivotTable is sorted or rearranged, and returns #REF! while Tables isn't showing. To get plain cell references instead, clear Generate GetPivotData in the Options menu on the PivotTable Analyze tab.
To check a figure against the list itself, total the same rows with SUMIFS. When the two agree, the report is right. How to create a pivot table in Excel works through that check on a sales report by region.
Example
One product line's three orders show why a calculated field divides the sums.
Common mistakes
- An average of a column of row margins. A small order weighs as much as a large one. Use a calculated field on the sums.
- A summary formula that types a PivotTable's address, such as
=B7. After the next sort or new item, B7 holds another figure. Click the cell instead, so Excel writes GETPIVOTDATA. - GETPIVOTDATA showing #REF! after a filter. The item it asks for isn't showing. Clear the filter or ask for an item that is.
In short
- Fields, Items, & Sets > Calculated Field adds a field worked out from the sums of other fields.
- A ratio in a calculated field divides totals, so big orders count for more.
- Clicking a PivotTable figure in a formula writes GETPIVOTDATA, which follows the item, not the address. SUMIFS on the list checks the figure.
Practice
Premium4 exercises: 2 PivotTables, 1 quiz question and 1 formula.
Practice is part of Premium
Every lesson is free to read, and you can practice the free lessons without an account. This lesson's exercises are part of Premium, which you add to a free account.
Have one? Sign in