Templates, guides & honest tool reviews for small business

Monday, November 30, 2026

Calculated Fields in a Pivot Table: Your Own Formula in the Values

Section: Excel & Google Sheets

Calculated fields - explanatory illustration for Calculated Fields in a Pivot Table
Illustration: Calculated fields

A calculated field in a pivot table adds your own formula to the values area, so a commission or a margin appears in the pivot, in the subtotals and in the grand total without a helper column in the source data. You find it under Analyze, then Fields, Items and Sets, then Calculated Field. This guide covers the difference between a calculated field and a calculated item, the exact steps for both, what the formula is allowed to use, why the maths works on totals rather than rows, and where Excel refuses to add one at all.

What a calculated field is

Microsoft lays out three ways to get numbers out of a pivot: summary functions in the values area, custom calculations such as percent of total or running total, and your own formulas in calculated fields and calculated items. The first two cover most reports. The third is for the case where neither gives the answer you need.

Base the pivot on an Excel Table and a refresh picks up new rows, which matters more here than usual: a calculated field only recalculates when the pivot does.

Microsoft's own example is a sales commission that differs by region. A calculated item can carry that formula, and the pivot then includes the commission in subtotals and grand totals automatically, which is the part a helper column cannot do.

Calculated field or calculated item

The distinction is in the names. Microsoft's guidance is to use a calculated field when the formula uses data from another field, and a calculated item when the formula uses specific items inside one field.

A commission on sales is a calculated field: it takes the Sales field and multiplies it. An estimate for a new product based on Dairy sales is a calculated item: it lives inside the Type field and refers to the Dairy item in that same field.

Calculated field or calculated item - explanatory illustration for Calculated Fields in a Pivot Table
Calculated field or calculated item (explanatory illustration, not a software screenshot).

Adding a calculated field

  1. Select the pivot table, which brings up the Analyze and Design tabs.
  2. On the Analyze tab, in the Calculations group, select Fields, Items and Sets, then Calculated Field.
  3. Type a name in the Name box.
  4. In the Formula box, enter the formula. To use another field, select it in the Fields box and select Insert Field.
  5. Select Add.

Microsoft's worked example is a 15 percent commission, entered as = Sales * 15% after inserting the Sales field. Typing the field name by hand works too, but only if it matches exactly, which is why the Insert Field button exists.

Adding a calculated field - explanatory illustration for Calculated Fields in a Pivot Table
Adding a calculated field (explanatory illustration, not a software screenshot).

What the formula can use

This is where most people hit a wall, and Microsoft is explicit about it. In a calculated field or item you can use operators, constants and references to data from the report, but you cannot use cell references or defined names. You cannot use worksheet functions that need cell references or defined names as arguments, and you cannot use array functions.

So =Sales*1.2 is fine, =SUM(Sales) is not, and a reference to a cell on another sheet is out of the question. The pivot is doing its own aggregation, and the formula has to work at that level.

What a pivot formula can use - explanatory illustration for Calculated Fields in a Pivot Table
What a pivot formula can use (explanatory illustration, not a software screenshot).

The maths works on totals, not rows

Microsoft states the difference between the two object types clearly. A calculated field formula operates on the sum of the underlying data for each field in the formula, so =Sales*1.2 multiplies the summed sales for each cell and not each individual sale.

A calculated item works the other way: =Dairy*115% multiplies each individual sale of Dairy and then summarises the results. For a straight multiplication the two give the same answer; for anything non-linear, such as a tiered rate or a rounding step, they do not, and that is the moment to think about which one you picked.

Names, quotes and totals

Field and item names identify the parts of the report inside the formula, and the syntax rules matter. A name with more than one word, or one containing numbers or symbols, needs single quotation marks around it. Formulas cannot refer to totals such as a month total or the grand total.

When two fields contain an item with the same name, write the field name in front of it, as in Region[North], to avoid a #NAME? error. Items can also be referenced by position, as in Type[1], but that reference moves when the items are sorted or hidden, so it is a fragile choice for a report someone else will open.

Calculated items, cell by cell

A calculated item can hold a different formula in different cells. Microsoft's example is an item with a formula of =Oranges*0.25 across all months, edited to =Oranges*0.5 for June, July and August. Select the cell, then type the change in the formula bar; hold Ctrl to change several cells at once.

This is the one place a pivot formula behaves like a worksheet, and it is easy to forget a cell is different. If a number looks wrong in one month only, check whether that cell carries its own formula before you rebuild anything.

Solve order and listing the formulas

With several calculated items, the order of calculation changes the result. Microsoft's Solve Order dialog, on the Analyze tab under Fields, Items and Sets, lets you select a formula and move it up or down. The same menu has List Formulas, which writes out every formula used in the pivot so you can read them together.

List Formulas is the fastest way to audit a pivot someone else built. It turns a black box into a short table of names and expressions.

Where formulas are not allowed

Microsoft is direct: you cannot create formulas in a pivot table connected to an OLAP data source, and you cannot change the summary function or add calculated fields or items there either. For OLAP sources the calculations are done on the server before Excel sees the values.

Pivots built on worksheet data or other non-OLAP sources are fine. If the Calculated Field option is greyed out, check the data source first.

Why the formula is greyed out - explanatory illustration for Calculated Fields in a Pivot Table
Why the formula is greyed out (explanatory illustration, not a software screenshot).

Common problems

  • #NAME? in the formula. A field or item name is spelled differently, or a multi-word name is missing its single quotes.
  • Calculated Field greyed out. The pivot is based on an OLAP source, or the workbook is in a state where the pivot cannot be edited.
  • A total that does not match the source. The formula works on summed values, not on each row. Rebuild it as a calculated item if you need row-level maths.
  • #DIV/0! in a margin field. The denominator is zero or blank for that cell. Guard it with an IF inside the formula.
  • A field that disappears after refresh. The source column was renamed. Rename it back or rebuild the field.
  • A grand total that is a sum of percentages. The calculated field is being summed across categories. Change the summary function for that field.

Questions and answers

Where is Calculated Field in Excel?

On the Analyze tab, in the Calculations group, under Fields, Items and Sets.

Can I use cell references in a pivot formula?

No. Constants and field or item names only, and no worksheet functions that need references.

Why is my calculated field wrong by a small amount?

The formula works on aggregated values. Rounding at the row level and rounding after aggregation give different totals.

Does a calculated field update when the source changes?

Yes, on refresh, as long as the fields it refers to still exist.

Is this the same in Google Sheets?

No. Google Sheets pivots have calculated fields of their own with a different interface. See pivot tables in Google Sheets before you copy a report across.

Official references

العربية