How to Achieve a Calculated Field Sum Divided by Count in a Pivot Table

Below, we have sales in amounts of different cities in a dataset. We want to calculate the average sale amounts of each city with or without imposed conditions. We can achieve this using the Pivot Table Calculated Field Sum, then dividing the Sum by the Total Sale Count.

Dataset-Pivot Table Calculated Field Sum Divided by Count

What is the Calculated Field in the Pivot Table?

For any dataset or range of data, we can insert a Pivot Table by going simply to the Insert tab > selecting Pivot Table from the Tables section.

All the entries in the Pivot Table are either text or number values. If we place the cursor on any entry, the PivotTable Analyze ribbon appears.

Caculated field-Pivot Table Calculated Field Sum Divided by Count

Issues with Calculating Field

The Pivot Table Calculated Field feature calculates the sum of other values. Nonetheless, the other values result from another execution, and the Calculated Field considers them summable.

For example, we have a Pivot Table where, for each city, there are multiple Order Dates.

We want to insert a Calculated Field that obeys the formula =’Order Date’ >3 as shown in the following image.

Issues with Calculated field

After applying the formula, we get the same result as True (i.e., 1) for each city depicted in the screenshot below. This is an issue. Test results should be 0 for Los Angeles and New York cities as they don’t satisfy the condition.

Faulty Result

The Pivot Table Calculated Field does that because the date field uses the COUNT function, and dates are added, whereas they should be counted.

To overcome this limitation of the Calculated Field, we must use a helper column as a count. Using the count column instead of the date, we’ll face no issue regarding the average calculation using the Calculated Field.

Inserting a Helper Column


  • Insert an extra column adjacent to the main dataset, and enter 1 in each cell.
  • Use the Fill Handle to insert 1 in cells.

Helper column-Pivot Table Calculated Field Sum Divided by Count

Inserting a Pivot Table


  •  Go to the Insert tab and Select Pivot Table (from the Tables section).

Inserting Pivot table

  • Executing Step 1 will automatically select the table range.
  • Select a different range according to your needs.
  • Mark the New Worksheet option.
  • Click OK.

Inserting Pivot table

The above two steps make the Pivot Table appear, as shown in the image below.

Pivot Table

Adding Fields to the Pivot Table


  • Tick the fields (e.g., City, Total, and Count) you want in the Pivot Table and place them in the Rows or Values section.

Adding fields in Pivot Table

  • Drag any fields around the Rows, Columns, or Values section as depicted in the following picture.

Fields Checked

Inserting a Calculated Field


  • Click on any values in the Pivot Table. The PivotTable Analyze ribbon appears.
  • Go to PivotTable Analyze ribbon > Select Fields, Item & Sets (from the Calculations section).

Calculated field-Pivot Table Calculated Field Sum Divided by Count

  • The Insert Calculated Field window pops up.
  • In the Insert Calculated Field window, Give the field a suitable Name (i.e., Target Total price).
  • Enter a formula (i.e., IF formula).
  • To enter any existing field, Select any field under the Fields section.
  • Click on Insert Field.

Inserted Calculated Field window

  • Enter the following formula in the Insert Calculated field:
=IF('Total Price'>500,'Total Price',"")
    • In the formula, we impose a condition using the IF function that we want Total Price amounts larger than 500.
  • Click OK.

Formula Insertion

  • After clicking OK, the Target Total Price amounts appear in the Sum of Target Total Price calculated pivot table field in the screenshot below.

Calculated field insertion

Calculated Field Sum Divided by Count


  • Give this calculated field a name (i.e., Average).
  • Enter the basic Average formula (i.e., Average=Target Total price/Count) as in the screenshot.
  • Click OK.

Calculated Field Sum Divided by Count

  • You see the average values as we divide the calculated field sum by the count. The latter illustration shows the Checked fields’ outcomes in a Pivot Table.

Pivot Table Calculated Field Sum Divided by Count

In the Pivot Table, we can achieve the average or Total Sum divided by Count in multiple alternative ways. However, the Calculated Field Sum divided by Count is knowingly calculable by adding a helper column, making each entry unique and countable by the Pivot Table. Otherwise, the Issue with the Calculated Field happens.

Read more: How to Get a Count in Excel Pivot Table Calculated Field

Alternative Way to Calculate the Average in a Pivot Table (without Calculated Field)


  • Insert a Pivot Table following Inserting a Pivot Table‘s sequences. The below picture shows a typical Pivot Table with fields.

Field Setting-Pivot Table Calculated Field Sum Divided by Count

  • Add an extra identical Sum of Total Price field in the Values section.
  • Drag the field to the Values section to add the field to the Values section.

Field insertion

  • Right-click on the added field in the Values section (i.e., Sum of Total Price).
  • Select Value Field Settings (from the Context Menu options).

Value Field Setting-Pivot Table Calculated Field Sum Divided by Count

  • Choose any calculation (i.e., Average) under Summarize value field by.
  • Click OK.

Average-Pivot Table Calculated Sum Divided by Count


  • The Average of the Sum Total Price value appears.

Average of Sum Total Price

Read More: How to Calculate Weighted Average in Excel Pivot Table

Note: Remember that Calculated Fields and typical Pivot Table Fields are not the same.  Calculated Fields are inserted fields that don’t exist in the Dataset.

Download the Excel Workbook

Related Articles

<< Go Back to Pivot Table Calculations | Pivot Table in Excel | Learn Excel

Get FREE Advanced Excel Exercises with Solutions!
Maruf Islam
Maruf Islam

MARUF ISLAM is an excellent marine engineer who loves working with Excel and diving into VBA programming. For him, programming is like a superhero tool that saves time when dealing with data, files, and the internet. His skills go beyond the basics, including ABACUS, AutoCAD, Rhinoceros, Maxsurf, and Hydromax. He got his B.Sc in Naval Architecture & Marine Engineering from BUET, and now he's switched gears, working as a content developer. In this role, he creates techy content... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF