Add a Calculated Field to a PivotTable

Excel Formulas › Analysis

All versionsCalculated Field

Need a metric the source data doesn’t have — margin %, average price, profit? A calculated field adds a formula inside the pivot that works on the summarized totals, no helper column required.


Quick formula: PivotTable Analyze → Fields, Items & Sets → Calculated Field:
Name: Margin % Formula: = Profit / Revenue
The new field appears in the field list and computes from the pivot’s aggregated values for every row.

The example

A margin % field computed inside the pivot.

AB
1ProductMargin %
2Widget37%
3Gadget35%

The formula

A formula that lives in the pivot:

Calculated Field → Name: "Margin %" Formula: =Profit / Revenue // computed on the pivot totals

How it works

Calculated fields operate on the summarized data:

  1. On the pivot, go to PivotTable Analyze → Fields, Items & Sets → Calculated Field.
  2. Give it a name and a formula using existing field names: =Profit / Revenue.
  3. It joins the field list; drag it into Values like any field.
  4. Crucially, it computes on the totals (SUM of Profit ÷ SUM of Revenue), not row-by-row — correct for ratios.

Calculated fields work on sums. “Margin %” = SUM(Profit)/SUM(Revenue), which is the right way to aggregate a ratio. Beware fields that average a per-row percentage — averaging percentages is usually wrong; recompute from the totals instead.

Try it: interactive demo

Live demo

Revenue & profit → margin % (on totals).

Margin %:

Variations

Average price

Calc field:

= Revenue / Units

Commission

Apply a rate:

= Sales * 0.05

Helper column instead

Add to source, then pivot it (row-level).

Pitfalls & errors

Operates on totals, not rows. Great for ratios, but it can’t do row-level logic (like an IF per transaction) — use a source helper column for that.

Use field names, not cells. Calculated-field formulas reference field names (Profit, Revenue), not cell addresses.

Limited functions. Calculated fields support basic math, not lookups or volatile functions. Complex logic belongs in the source.

Practice workbook

📊
Download the free Add a Calculated Field to a PivotTable practice workbook
Source data with a margin = profit/revenue example (calculated field on the page), plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I add a calculated field to a PivotTable?
PivotTable Analyze → Fields, Items & Sets → Calculated Field. Name it and enter a formula using field names, e.g. =Profit / Revenue. It computes on the pivot's totals.
Does a calculated field work row by row?
No — it operates on the summarized totals (SUM of Profit / SUM of Revenue). For row-level logic, add a helper column to the source data instead.
Why is averaging a percentage field wrong?
Averaging per-row percentages ignores weighting. Recompute ratios from the totals — a calculated field of SUM(Profit)/SUM(Revenue) does this correctly.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Pivot percent of total · Profit per product · Profit margin vs markup