|
Home > Pivot > Calculation > Calculated Field
Excel Pivot Table Calculated Field
|

|
In a pivot table, you can create calculated fields, using your own custom formulas, like the one shown below. See how to add this powerful tool to the pivot tables in your Excel workbook, step by step!
|
|

1. Pivot Table Formulas
In a pivot table, you can create your own formulas, using Calculated Fields and Calculated Items.
Tip: Another way to add custom calculations is with the pivot table Show Values As settings. For example, quickly show Difference From, Running Total, or Rank, without adding your own formulas.
Calculated Field Workbook
2. Pivot Table Calculated Field
A pivot table calculated field uses a formula that you create, and the formula can refer to other fields in the pivot table.
For example, in the screenshot below, I'm creating a calculated field named RepBonus.
- The formula refers to the Total field.
- The formula result is the sum of the Total amounts, multiplied by 3%

2.1) About Calculated Fields
Here are some facts and limitations for calculated fields:
Facts
- New Field: When you create a calculated field, it's added to the pivot table's field list, below the fields from the source data
- Sum: If the formula refers to other fields, the individual amounts in the other value fields
are summed. The calculation is performed on that total amount.
- Pivot Cache: Calculated fields that you create are automatically available in all other pivot tables that are based on the same pivot cache
- Values: Calculated fields appear in the Values area, so the result should be a number, or a boolean value (TRUE or FALSE)
- Boolean results show as 1 (TRUE) or 0 (FALSE)
Limitations
- Totals: Calculated field formulas can't refer to the pivot table totals
or subtotals
- Cells: Calculated field formulas can't refer to worksheet cells. You can't put cell addresses in the formula, or refer to named ranges.
- OLAP: Calculated fields are not available in an OLAP-based pivot table
- Note: If you checked the "add to Data Model" box, your pivot table is OLAP-based
- Sum: If the formula refers to other fields, the sum of that field's
values are used, even if the pivot table shows a count for that field.
3) Add a Simple Calculated Field
For a quick overview of calculated fields, you can watch this video. In the video, I show the steps for creating a simple calculated
field. The written steps are below the video.
Tip: To follow along, you can get the sample file for this video in the download section, below.
3.1) Example - Add Simple Calculated Field
In this example, the pivot table layout has 4 fields:
- Rep field in Row area (Sales rep name)
- Product field in Row area (Product name)
- Units field in Values area
- Sum of units sold, for Rep and Product
- Total field in Values area
- Sum of sales revenue, for Rep and Product

3.2) Calculated Field Plan
Based on those pivot fields, I want to calculate a 3% bonus for sales reps.
Here's my plan, to add a RepBonus field (column) in the Values area:
- I'll create a new calculated field, named RepBonus
- The RepBonus formula will multiply:
- sum of Total sales in each row
- by 3%
- In cell D5 on the worksheet, I'd use this formula:
- For the Calculated field, I'll use the field name, instead of the cell reference:
Tip: To follow along with the detailed steps below, you can get the sample file for this video in the download section, below.
3.3) Quick Steps - Add Calculated Field
Here's the short version of the steps I followed, to add a calculated field named RepBonus.
- Select any cell in the pivot table
- On the Excel Ribbon, go to the PivotTable Analyze tab
- Click Fields, Items, & Sets, then click Calculated Field
- In the Insert Calculated Field dialog box, type: RepBonus
- In the Formula box, type: =Total * 3%
- Click the Add button
- Back on the worksheet, the RepBonus field appears in the pivot table layout and in the PivotTable Field List

3.4) Detailed Steps - Add Calculated Field
In this section, there are the detailed steps for creating a pivot table calculated field, with screenshots, tips, and warnings.
Get Started
To add a calculated field named RepBonus, start with these steps:
- To start, select any cell in the pivot table
- Next, on the Excel Ribbon, go to the PivotTable Analyze tab
- In the Calculations group, click Fields, Items, & Sets
- Then, in the drop-down menu, click the Calculated Field command

3.4.1) Insert Calculated Field Dialog Box
The Insert Calculated Field dialog box opens, where you can create a new calculated field, or make changes to existing calculated fields
- The Name and Formula boxes contain default entries:
- Field1, and "=0" in the screenshot below.
- There's also a list of all existing pivot table fields.

3.4.2) Name the Calculated Field
The next step is to name the calculated field:
- First, I deleted the default name in the Name box
- Next, I typed RepBonus in its the Name box
Field Name Warning
No duplicates field names are allowed in an Excel pivot table
- Be sure that the calculated field name you choose is not already used in the pivot table
Here's what happens if you enter a field name that already exists:
- Source Data Field: If you enter the name of an existing source data field,
- Excel will not respond when you click the Add button
- Calculated Field: If you enter the name of an existing calculated field:
- Excel will replace that calculated field's formula with the new formula that you enter
- It will not ask you to confirm the change
3.4.3) Enter the Formula
Next, I followed these steps to add the RepBonus formula. I want to multiply the Total field by 3%.
- Here's the completed formula: =Total * 3%
Here are the steps I followed to create that formula, with a few tips for entering the formula quickly and accurately.
- From the Name box, press the Tab key on the keyboard, to move to the Formula box
- Existing formula will be automatically selected
- You can type over it, or delete it,
- To start the formula, type an Equal sign: =
Add the Field Name
- Next, instead of typing the "Total" field name, you can do this:
- Find the Total field in the list of Fields
- Double-click on the Total field name, to add it to the formula
- This helps you enter the name quickly, without typos!
- OR, if you prefer to use the keyboard:
- tab to the Fields list, and use the keyboard arrow keys to select the Total field.
- Then, press the Enter key, to activate the Insert Field button
Note: A space character is automatically added after the equal sign. You can leave that as is.
Finish the Formula
- Next, in the Formula box, type the rest of the formula:
- Optional: You can add space characters before and after the asterisk, so the formula is easier to read
- Do not put a space character between the 3 and % (percent operator)

3.4.4) Add the Calculated Field
Here are the final steps to follow:
- Click the Add button to save the calculated field
- The new calculated field is added to the Fields list in the dialog box, below the existing fields
- Scroll down the list, to see the new field's name
- Then, click the Close button, to close the dialog box, and return to the worksheet.
- OR, create another calculated field, if you need one!
- Then, click the Close button when you're finished
3.4.5) New Field in Pivot Table
When you return to the Excel worksheet, the pivot table has a new field named RepBonus. The new field appears in 2 places:
- In the Values area of the pivot table worksheet layout, to the right of the other Value fields - Units and Total.
- At the bottom of the check box list of fields, in the PivotTable Field List.

3.4.6) Change Field Caption (Optional)
In the pivot table layout, the new field has "Sum of" at the start of its caption.
To make the caption shorter, I usually type a different caption in the heading cell.
- ▶ Note: The caption cannot be exactly the same as any of the pivot table's field names.
Here are the steps:
- In the screen shot below, I selected cell D4
- Then, to replace the long caption, I typed "RepBonus ", and then pressed the Enter key
- Important: There is a space character at the end of that caption, to make it different from the "RepBonus" field name
- In the worksheet heading, the space character isn't noticeable
Now, with the shorter field caption, I can make the column narrower, so the pivot table is easier to read

4) Change or Remove Calculated Field
After you create a calculated field, you might need to change its formula. Or, you might want to remove a calculated field, if you no longer need it in the pivot table.
--4.1) Change Calculated Field
--4.2) Remove Pivot Table Calculated Field
4.1) Change a Calculated Field
After you create a calculated field, you might need to change its formula. In this example, we'll change the Bonus percentage for the calculated field formula that was created in the previous section.
I show the steps in this video, and the written steps are below the video. To get the sample file for this video, go to the download
section, below.
- Follow the steps above, to open the Calculated
Field dialog box
- Click the arrow in the Name box, and select the calculated field that you want to modify -- Bonus in this example.

- In the Formula box, make changes to the formula -- in this example, I changed the percentage from 3% to 4%:
- =IF(Units>100,Total*4%,0)
- Click the Modify button, to save the calculated field changes, then click Close.

4.2) Remove a Calculated Field
In this example, the pivot table has a calculated field named Bonus. It appears in the Values area as Sum of Bonus. You could temporarily hide the Bonus calculated field, or permanently delete it from the pivot table.
--4.2.1) Temporarily Remove Calculated Field
--4.2.2) Manually Remove Calculated Field
4.2.1) Temporarily Remove a Calculated Field
To temporarily remove a calculated field from a pivot table, follow
these steps:
- In the pivot table, right-click a cell in the calculated field.
In this example, we'll right-click the Bonus field.
- In the popup menu, click the Remove command that shows the name of the calculated field.
The calculated field is removed from the pivot table layout, but
remains in the PivotTable Field List.
Later, you can add a check mark to the calculated field in the PivotTable
Field List, to return it to the pivot table layout.
4.2.2) Permanently Remove a Calculated Field
To permanently remove a calculated field, follow these steps to delete
it:
- Select any cell in the pivot table.
- On the Ribbon, under the PivotTable Tools tab, click the
Options tab (Analyze tab in Excel 2013).
- In the Tools group, click Formulas, and then click Calculated
Field.
- From the Name drop down list, select the name of the calculated
field you want to delete.
- Click Delete, and then click OK to close the dialog box.
After you add calculated fields or calculated items in a pivot table, you can create a quick list of all the formulas in those calculations.
This is helpful if you need to document your Excel file, or do some troubleshooting.
5.1) Create Quick List of Pivot Formulas
With a built-in command, you can quickly create a list of the calculated
fields and calculated items in the selected pivot table, and their formulas.
I show the steps in this short videos, and there are written steps are below the video.
5.1.1) Create List of Pivot Table Formulas
With a built-in pivot table command, you can quickly create a list
of the calculated fields and calculated items in the selected pivot
table.
|
▶
|
|
Note: All pivot tables that share the same pivot cache will also share the same calculated fields and calculated items.
|
Steps - List Pivot Table Formulas
To create a list of the pivot table formulas, follow the steps below:
- Select any cell in the pivot table.
- On the Ribbon, under the PivotTable Tools tab, click the Analyze
tab (Options tab in some Excel versions).
- In the Calculations group, click Fields, Items & Sets
- Click List Formulas.

New Sheet with List
A new sheet is inserted in the workbook, with a list of the pivot table's calculated
fields and a calculated items list.
- Calculated fields (if any), are listed first
- Calculated Items (if any), are listed second
- Solve Order is also shown, for calculated fields and calculated items
For details on how Solve Order works, go to the Pivot Table Calculated Items page.

6) Download the Sample File
- Calculated Field Examples: Sample file for the Simple Calculated field and Complex Calculated
Field tutorials:
Calculated Field Samples
7) Down the Rabbit Hole 🐰
In this section, you'll find related Excel tips, shortcuts, skills, and details. These things are nice to know, but not essential, so you can skip this section, and get back to work. Or dive in, for some extra Excel fun and knowledge!
--8.1) Calculated Field Vs Calculated Item
--8.2) Sum Is Always Used
--8.3) Problem - Calculated Field Totals
7.1) Calculated Field Vs Calculated Item
Along with Calculated Fields, pivot tables also have another type of formula -- Calculated Items.
Calculated Items are similar to Calculated Fields, and let you create custom formulas. However:
- Calculated fields can use the sum of other pivot fields in the pivot table
- Calculated items can only use the sum of other items within the same pivot field.
Video: Calculated Field vs Calculated Item
This short video shows the steps to create custom formulas in Excel pivot table with calculated fields and calculated items.
If you aren't sure which custom calculation type to use, see my notes on the difference between Calculated Items and Calculated Fields.
7.2) Calculated Field Always Uses Sum
When referring to other pivot fields in a calculated field, the SUM of that field's values is always used, even if a different function, like COUNT, is used in the pivot table.
Here's an example, using sales data that has:
- text ID for each order (AD0001)
- number of Units sold for each order (36)
For each product, I want to calculate the number of units sold per order.
- Sum of Units / Number of Orders

7.2.1) Pivot Table Setup
To see a summary, I built a pivot table, based on the sales data, with the following fields in the layout:.
- Product in Row area
- Units in Values area, summarized by Sum
- ID in Values area, summarized by Count
7.2.2) Calculated Field
Next, I added a calculated field, PerOrder, to calculate the number of units sold per order
- In the calculated field, PerOrder, the formula is:

7.2.3) Errors in Calculated Field
When I clicked the OK button, to add the PerOrder field, the new column was full of #DIV/0! errors (divide by zero error).
- For Binder, the result should be 52.4 (786 / 15)
- The #DIV/0! error means that it divided by zero, instead of 15

7.2.4) Calculated Field SUM Limitation
In a calculated field, if you refer to any pivot table field, that field's SUM is always used:
- Even if a value field is summarized by COUNT, that function will be ignored
- There is no way to choose a different function -- the calculated field will always SUM the other field's values
7.2.5) Show Values As SUM
To troubleshoot the ID field problem, I followed these steps, to change the ID column, from COUNT to SUM:
- Right-click a number in the ID column, and click on Value Field Settings
- In the Summarize Value Field By list, click on Sum
- Click OK to close the Value Field Settings dialog box
- In the pivot table, all the ID values changed to zero
The PerOrder formula:
- divides the sum of Units, by the sum of ID values.
- Dividing by zero in each row results a #DIV/0! error
Text Field Values
Here's why the sum of ID is zero:
- The ID field is text (AD0001)
- In Excel, text has a numeric value of zero
- The sum of all the zero ID values for each product is zero
7.2.6) Workaround: Add Field in Source Data
You can't change the calculated field limitation of always using SUM.
- So, for data where I want a count of text fields, I add a new column to the pivot table's source date.
- In the screen shot below, the new column is named Orders
- In cell J2, I entered this simple formula: =1
- Because the list is a named Excel table, the formula automatically filled down to the last row.
- Also, any new row will automatically have that formula
Change the Pivot Table
Next, I did the following steps:
- I refreshed the pivot table, so the Orders field was listed in the PivotTable Field List.
- Then, I removed the ID field from the Values area
- I added the Orders field to the Values area, where it automatically shows a sum
- Finally, I changed the formula in the PerOrder calculated field, to use Orders instead of ID
- As soon as I clicked OK, to close the dialog box, the PerOrder column showed the correct result, instead of errors.
- (Optional) As a clean up step, I formatted the PerOrder column with Number format, showing zero decimals.
7.2.7) Video: Use Count in Calculated Field
Watch this video to see how to create a pivot table, add a new counter field to the source data, and create a calculated field using the counter field. There are written steps on the Calculated Field Count page.
7.3) Problem - Calculated Field Totals
When you create a calculated field, you might expect to see a sum
of the calculated amounts, in the pivot table's subtotal and grand
total rows.
However, the calculated field uses the same calculation
in the subtotal and grand total rows, instead of showing a sum.
For example, in the Bonus calculated field, shown below:
- The total
bonus for Andrews is 164.23, instead of 70.13 (23.65+33.83+12.65).
- This happens because Excel uses the same calculation in the Total
and Subtotal rows, instead of summing the amounts.
- The total Units for Andrews is greater than 100, so the total Bonus
is calculated as 3% of Andrews' Total.

7.3.1) Totals - Problem Workarounds
There isn't a pivot table setting that you can change, so it will
sum the calculated fields, instead of using the calculated field formula
on the totals.
However, you could try one of the three workarounds shown below
a) Apply a Filter
To hide the rows that don't qualify for a bonus, filter the product
field for Units > 100, to match the Bonus calculation. With the filter
applied, the subtotals and Grand Total are correct.

b) Hide Subtotals and Grand Totals
Another workaround is to remove the Subtotals and Grand Totals from
the Sales Rep field.
- To turn off the Subtotals, right-click on one of the Sales Rep
names, and click Subtotal "Rep", to remove the check mark.
- To turn off the Grand Total, right-click on the Grand Total label,
and click Remove Grand Total.

b) Calculate Outside of Pivot Table
If your pivot table layout rarely changes, another workaround is to
calculate the Subtotals and Totals, outside of the pivot table, in
columns to the right.
- Note: For this technique to work correctly, change
the pivot table layout to Outline Form.
In the screen shot below, the bonus is a calculated field, in column
P. Formulas have been added in columns Q, R and S, and column Q has
conditional formatting, so it matches the pivot table style.
- Formula in cell R12: =IF(L12="",R11,SUM(R11,1))
- Formula in cell S12: =IF(M12="",0,P12)
- Formula in cell Q12: =IF(L12="Grand Total",SUM(S:S),IF(L12<>"",SUMIF(R:R,R12,S:S),S12))
Copy the formulas down to row 22, where the Grand Total is located.
Then, columns P, R and S could be hidden, leaving only the calculated
Bonus in column Q.

Get Monthly Excel Tips!
Don't miss my monthly Excel newsletter! You'll get quick tips, article links, and a bit of fun. Add your email, and click Sign Up.
Next, when you get my reply, click the Confirm button. I add this step to protect you from spam!
|
More Pivot Table Tutorials
Calculated Items vs Calculated Fields
Calculated Field Macros
Calculated Field - Count
PIVOTBY Function
Calculated Items
FAQs - Pivot Tables
Pivot Table Introduction
Grouping Data
Multiple Consolidation Ranges
Running Totals
Summary Functions
Clear Old Items in Pivot Table