Home > Pivot > Calculation > Calculated Field

Pivot Table Calculated Field Advanced Examples

Debra Dalgleish - Contextures

In a pivot table, you can create calculated fields, using your own custom formulas, like the one shown below. This page has examples of advanced pivot table calculated fields.

create calculated field with ROUND function

1) Get Started - Open the Dialog Box

To add, modify or delete a calculated field, start with these steps, to open the Insert Calculated Field dialog box:

  1. First, select any cell in the pivot table
  2. On the Excel Ribbon, go to the PivotTable Analyze tab
  3. Click Fields, Items, & Sets, then click Calculated Field
  4. The Insert Calculated Field dialog box opens

A default name and formula are filled in:

  • A numbered name is in the Name box, e.g. Field1
  • A basic formula is in the Formula box, e.g. = 0

open the Insert Calculated Field dialog box

2) Ex 1: Conditional Bonus

In this example, the pivot table shows the product sales, for each sales rep, with:

  • number of units sold
  • total sales dollars

If a sales rep sells more than 100 units of a product, they'll earn a 3% bonus on that product's total sales dollars.

I've marked those rows with a check mark, in the screen shot below.

✅  To follow along, get the Excel sample file in the download section

conditional bonus if over 100 units sold

2.1) Conditional Bonus Formula

To calculate the bonus amounts in the pivot table, you can create a new calculated field.

Usually, I create a worksheet formula first, to test the calculation.

In the screen shot below, the formula in cell E6 uses the Excel IF function.

  • =IF(C6>100,D6*3%,0)

The test is: C6>100   (Is the number of units greater than 100?)

  • If that is TRUE, the formula returns the value from cell D6 multiplied by 3%
  • If FALSE, the formula returns zero (no bonus amount)

conditional bonus if over 100 units sold

2.2) Add a calculated field

The IF formula works correctly on the worksheet, so I'll create a calculated field withthe same formula. Instead of cell references, the formula will use field names.

To add the new calculated field dialog, follow the steps below:

  • First, follow the steps above, to open the Insert Calculated Field dialog box
  • Next, in the Name box, type a name for the calculated field
    • The name is Bonus, in this example.
  • In the Formula box, type the following IF formula, that refers to the Units and Total fields:
    • =IF(Units>100,Total*3%,0)
  • Click the Add button, to save the new calculated field
  • Click the Close button, to return to the Excel worksheet

add enw field in the Insert Calculated Field dialog box

2.3) On the Worksheet

On the worksheet, the Bonus field appears in the Values area of the pivot table.

  • The bonus of 3% is applied for product sales over 100 units.

The Bonus field also appears in the PivotTable Field List, below the source data fields.

new Calculated Field in pivot table and pivot table field list

3) Ex 2: Sales Projections

In this calculated field example, I use Excel rounding functions - ROUND or MROUND - in a calculated field formula, to project product sales for the upcoming quarter.

  • Note: You can get the sample file for this example in the download section, below

3.1) Pivot Table - Sales Projections

In this pivot table shown below, the first quarter sales for each product are summarized

first quarter sales in pivot table

To forecast the second quarter sales, I'll create two calculated fields, based on the number of units sold.

  1. Dn03 - a pessimistic projection - sales will go down 3%
    • The multiplier will be 0.97      ( 100-3=97 / 100 = 0.97)
  2. Up05 - an optimistic projection - sales will go up 5%
    • The multiplier will be 1.05      ( 100=5=105 / 100=1.05 )

Note: Usually, I like to put variables on a worksheet, so they're easy to see and adjust. However, calculated field formulas can't refer to worksheet cells, so I'll type those multipliers into the formulas.

3.2) Create Pessimistic Projection

To create the calculated field for the pessimistic sales forecast (down 3%), follow the steps below:

  • First, select a cell in the pivot table, and follow the steps above, to open the Insert Calculated Field dialog box
  • Type a name for the new calculated field, Dn03
  • In the Formula box, type the following formula (see notes below, on how this function works), using the 0.97 multiplier:
    • =ROUND(Units * 0.97, 0)
  • Click Add to save the new calculated field
  • Next, click the Close button, to go back to the worksheet.

create calculated field with ROUND function

3.3) Pessimistic Projection in Pivot Table

The Dn03 calculated field automatically appears in the pivot table, to the right of the existing value field (Units).

  • The calculated field's default heading was "Sum of Dn03"
  • I typed a new heading: "Dn 3%".

create calculated field with ROUND function

3.4) How Dn03 Formula Works

The Dn03 calculated field formula uses the ROUND function, which rounds a number to the closest number, and with a specific number of digits rounded.

  • =ROUND(Units * 0.97, 0)

The ROUND function has two arguments, and both are required:

  • number - the value to be rounded (Units * 0.97)
  • num_digits - the number of digits to which the value should be rounded, to the left or right of the decimal point (0)

3.5) Create Optimistic Projection

Next, to create a calculated field for the optimistic sales forecast, I followed these steps:

  • First, select a cell in the pivot table, and follow the steps above, to open the Insert Calculated Field dialog box
  • Type a name for the new calculated field, Up05
  • In the Formula box, type the following formula (see notes below, on how this function works), using the 1.05 multiplier::
    • =MROUND(Units * 1.05, 5)
  • Click Add to save the new calculated field
  • Next, click the Close button, to go back to the worksheet.

create calculated field with rounding

3.6) Optimistic Projection in Pivot Table

The Up05 calculated field automatically appears in the pivot table, to the right of the existing value fields (Units and Dn 3%)

  • The calculated field's default heading was "Sum of Up05"
  • I typed a new heading: "Up 5%".

create calculated field with rounding

3.7) How Up05 Formula Works

The new calculated field formula uses the MROUND function, which rounds a number to a specific multiple.

  • =MROUND(Units * 1.05, 5)

The MROUND function has two arguments, and both are required:

  • number - the value to be rounded (Units * 1.05)
  • multiple - the multiple to which the value should be rounded (5)

3.8) How MROUND Function Works

To determine if it should round up or down, the MROUND function uses this test:

  • divide the number by the multiple
  • find the remainder of that division
  • divide the multiple in half

Is the remainder less than half of the multiple?

  • YES - round down ▼, toward zero
  • NO - round up ▲, away from zero
Worksheet - MROUND Function

In the screenshot below, I've put a worksheet example of the MROUND function, to show how its rounding works.

In the formula, the multiple is 5, so half of that is 2.5.

  • Cell D2: remainder from 126/5 is 1
    • 1 is less than half of 5 (2.5), so it rounds down ▼
  • Cell D3: remainder from 133.4/5 is 3.4
    • 3.4 is not less than half of 5 (2.5), so it rounds up ▲

create calculated field with rounding

4) Download the Sample File

  1. Calculated Field Examples: Sample file for the Simple Calculated field and Complex Calculated Field tutorials: Calculated Field Samples

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

Pivot Table Calculated Fields

Calculated Field - Count

PIVOTBY Function

Calculated Items

FAQs - Pivot Tables

Pivot Table Introduction

Grouping Error

Multiple Consolidation Ranges

Running Totals

Summary Functions

Clear Old Items in Pivot Table

 

 

Last updated: September 13, 2025 12:20 PM