After you create a pivot table, you can enhance the results by writing your own formulas, to create calculated fields and calculated items. e When you’re getting started with formulas, it might not be clear what the difference is. When should you use a calculated field and when should you create a calculated item?
We’ll take a look at a pivot table that uses both types of formulas, and see where and how they work. You can also find more information on each type of formula on my Contextures website:
- Formulas are available only in non-OLAP-based pivot tables
- You can’t create formulas that refer to the pivot table totals or subtotals.
- Formulas can’t refer to worksheet cells by address or by name.
- You can create a list of all the formulas in a pivot table.
About Calculated Items
- A calculated item becomes an item in a pivot field. Its calculation can use the sum of other items in the same field.
- For calculated items, the individual records in the source data are calculated, and then the results are summed.
- Calculated items are listed with other items in the Row Labels or Columns area of the pivot table.
- Calculated items are not listed in the PivotTable Field List.
Warning: If you create a calculated item in a field, you will:
- NOT be able to move the field to the Report Filters area
- NOT be able to add multiple copies of a field to the Values area.
About Calculated Fields
- Use calculated fields to perform calculations on other fields in the pivot table.
- For calculated fields, the individual amounts in the other fields are summed, and then the calculation is performed on the total amount.
- Sum is the only function available for a calculated field.
- A calculated field becomes a new field in the pivot table, and its calculation can use the sum of other fields.
- Calculated fields appear with the other value fields in the pivot table. Like other value fields, a calculated field’s name may be preceded by Sum of.
- Calculated fields appear in the PivotTable Field List.
Calculated Item Example
You can create a calculated item when you want to perform calculations on specific items in a pivot field.
In the example shown below, the Order Status field has four items – Backorder, Canceled, Pending and Shipped.
In the Order Status field, you could create a calculated item named Sold, that sums the orders with a status of Shipped, Pending, or Backorder, but doesn’t include Canceled orders.
In the screen shot below, the Sold calculated item is showing, and the Backorder, Pending and Shipped items have been hidden.
When to Use a Calculated Field
Use calculated fields to perform calculations on other fields in the pivot table. In this example, each sales representative receives a 3% bonus if they sold more than 500 units.
The calculated field formula checks the value in the Units field, and calculates the bonus amount based on 3% of the Total field.
Here is the result, with the bonus showing in the applicable rows. The calculated item is used to create a total of all the Sold items (Backordered, Pending and Shipped).
NOTE: A calculated field cannot check the text value of a label, so use filtering or calculated items to show only the applicable items.