Create, edit, or delete a PivotTable or PivotChart formula
If summary functions and custom calculations don't provide the results that you want, you can create your own formulas in calculated fields and calculated items . For example, you could add a calculated item with the formula for the sales commission, which could be different for each region. The PivotTable report would then automatically include the commission in the subtotals and grand totals.
Notes:
- You cannot create formulas in a PivotTable or PivotChart report that is connected to an OLAP source data.
- For best results in a PivotChart report , work in the associated PivotTable report where you can see the individual data values that your formula calculates.
Create a formula
- Decide whether you want a calculated field or a calculated item within a field.
- Use a calculated field when you want to use the data from another field in your formula.
- Use a calculated item when you want your formula to use data from one or more specific items within a field.
- Do one of the following.
Add a calculated field
- Click the PivotTable report.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickCalculated Field. - In the
Namebox, type a name for the field. - In the
Formulabox, enter the formula for the field.To use the data from another field in the formula, click the field in the
Fieldsbox, and then clickInsert Field. For example, to calculate a 15% commission on each value in the Sales field, you could enter= Sales * 15%. - Click
Add.
Add a calculated item to a field
- If items in the field are grouped, on the
Optionstab, in theGroupgroup, clickUngroup. - Click the field where you want to add the calculated item.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickCalculated Item. - In the
Namebox, type a name for the calculated item. - In the
Formulabox, enter the formula for the item.To use the data from an item in the formula, click the item in the
Itemslist, and then clickInsert Item(the item must be from the same field as the calculated item). - Click
Add. - If you ungrouped items in step 1, regroup them if you want. For more information, see Group items in a PivotTable or PivotChart field
- For calculated items, you can enter different formulas cell by cell.
For example, if a calculated item named OrangeCounty has a formula of =Oranges * .25 across all months, you can change the formula to =Oranges *.5 for June, July, and August.
Do the following:
- Click a cell for which you want to change the formula.
To change the formula for several cells, hold down CTRL and click the additional cells.
- In the formula bar , type the changes to the formula.
- Click a cell for which you want to change the formula.
- If you have multiple calculated items or formulas, adjust the order of calculation by doing the following:
- Click the PivotTable report.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickSolve Order. - Click a formula, and then click
Move UporMove Down. - Continue until the formulas are in the order that you want them to be calculated.
Display a list of formulas
To display a list of all the formulas used in the current PivotTable report, do the following:
- Click the PivotTable report.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickList Formulas.
Edit a formula
- Determine whether the formula is in a calculated field or a calculated item . If the formula is in a calculated item, determine whether the formula is the only one for the calculated item by doing the following:
- Click the PivotTable report.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickList Formulas. - In the list of formulas, find the formula that you want to change listed under Calculated Field or Calculated Item.
When there are multiple formulas for a calculated item, the default formula that was entered when the item was created has the calculated item name in column B. For additional formulas for a calculated item, column B contains both the calculated item name and the names of intersecting items.
For example, you might have a default formula for a calculated item named
MyItem, and another formula for this item identified asMyItem January Sales. In the PivotTable report, you would find this formula in the Sales cell for the MyItem row and January column.
- Do one of the following:
Edit a calculated field formula
- Click the PivotTable report.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickCalculated Field. - In the
Namebox, select the calculated field for which you want to change the formula. - In the
Formulabox, edit the formula. - Click
Modify.
Edit a single formula for a calculated item
- Click the field that contains the calculated item.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickCalculated Item. - In the
Namebox, select the calculated item. - In the
Formulabox, edit the formula. - Click
Modify.
Edit individual formulas for specific cells of a calculated item
For example, if a calculated item named OrangeCalc has a formula of =Oranges * .25 across all months, you can change the formula to =Oranges *.5 for June, July, and August.
- Click a cell for which you want to change the formula.
To change the formula for several cells, hold down CTRL and click the additional cells.
- In the formula bar , type the changes to the formula.
- If you have multiple calculated items or formulas, adjust the order of calculation by doing the following:
- Click the PivotTable report.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickSolve Order. - Click a formula, and then click
Move UporMove Down. - Continue until the formulas are in the order that you want them to be calculated.
Delete a formula
Tip If you don't want to delete a formula permanently, you can hide the field or item. To hide a field, drag it out of the report.
- Determine whether the formula is in a calculated field or a calculated item .
Calculated fields appear in the PivotTable Field List. Calculated items appear as items within other fields.
- Do one of the following:
Delete a calculated field
- Click the PivotTable report.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickCalculated Field. - In the
Namebox, select the field that you want to delete. - Click
Delete.
Delete a calculated item
- Click the field with the item that you want to delete.
- On the
Optionstab, in theToolsgroup, clickFormulas, and then clickCalculated Item. - In the
Namebox, select the item that you want to delete. - Click
Delete.
![]()