|
Home > Pivot > Calculation > Summary Functions Pivot Table Summary Functions
|

When you add a field to the pivot table's Values area, 11 different functions, such as Sum, Count and Average, are available to summarize the data.
The summary functions in a pivot table are similar to the worksheet functions with the same names, with a few differences as noted in the descriptions that follow.

When you add a numerical field to the pivot table's Values area, Sum or Count will be the default summary function. The default function can't be changed -- it's applied based on the field's contents:
After a field has been added to the pivot table, to select a different summary function, follow these steps:

The selected summary function will automatically be used in the subtotals and grand totals for that field. You can select a different function for the totals -- see the instructions here.
However, the totals calculated on the source data, not on the values showing in the pivot table. For example, if a field uses the MAX summary function, and the subtotal shows the AVERAGE, it will be an average from the values in the source data, not an average of the MAX values. (To calculate the Average of the Max values, you could use formulas outside of the pivot table, or create a new pivot table, based on the original one.)
To change many fields at once, you can use a macro.
The pivot table's Sum function totals all the underlying values for each item in the field. The result is the same as using the SUM function on the worksheet to total the values. Blank cells, and cells with text are ignored.
In the screen shot below, you can see the source data for a small pivot table, and the total quantity, using the worksheet's SUM function, is 317.

With a pivot table, you can quickly see the total sum for each product
that was sold, and the grand total -- 317 -- which matches the worksheet
total. ![]()

Instead of manually changing each data field to the Sum function, you can run a macro that will change the summary function in each data field.
You can copy this code to a regular code module in your workbook, and run it when you want to change the summary functions for all the Value fields.
Sub SumAllValueFields()
Dim pt As PivotTable
Dim pf As PivotField
Dim ws As Worksheet
Set ws = ActiveSheet
Set pt = ws.PivotTables(1)
Application.ScreenUpdating = False
pt.ManualUpdate = True
For Each pf In pt.DataFields
pf.Function = xlSum
Next pf
pt.ManualUpdate = False
Application.ScreenUpdating = True
Set pf = Nothing
Set pt = Nothing
Set ws = Nothing
End Sub
Count is the default summary function when fields with nonnumeric or blank cells are added to the Values area. The Count function's name is slightly confusing, because it's like the COUNTA worksheet function, not the COUNT worksheet function.
The pivot table Count function counts:
Blank cells are NOT counted.
In a pivot table, the Count function does not count blank cells. So, if you need to show counts that include all records, choose a field that has data in every row.
This short video shows two examples, and there are written steps below the video.
In the product sales data shown below, cell C7, in the Qty column, is blank.

Using that product sales data, we want to create a pivot table that shows the number of orders for each product.
To get the pivot table started, follow these steps:

Usually, we put numeric fields into the Values area of a pivot table.
To see what happens with this data, follow these steps:
Because one of the Qty cells is blank, it is not counted.

To get the count of all orders, even if the Qty cells are blank, follow these steps:
Because none of the Product cells are blank, the count includes all the orders.
TIP: Rename the Count of Product column as "Orders"

The Average function totals all the underlying values in the Values area, and it divides by the number of values. The result is the same as using the AVERAGE function on the worksheet to calculate the average (mean) of the values.
Blank cells, and cells with text, are ignored when calculating the pivot table averages, but zero cells are included.
In the data source shown below, cell C7 is blank, and is not included in either the worksheet average (C12), or the pivot table average, shown below.

If you have formatted the worksheet to hide zero values, remember that those zero values will be included in the averages, even if the cells appear blank.
When you use the Average summary function, the results will probably show a strange mixture of decimal places, as shown in the pivot table at the left, in the screen shot below.
Format the field to have a consistent number of decimal places (as in the pivot table at the right, below), so the numbers are easy to compare.
The Max summary function shows the maximum value from the underlying values in the Values area. The result is the same as using the MAX function on the worksheet to calculate the maximum of the values.
In the screen shot below, you can see the source data for a small pivot table, and the maximum quantity, using the worksheet's MAX function, is 97.

With a pivot table, you can quickly see the maximum for each product
that was sold, and the grand total -- 97 -- which matches the worksheet
maximum. ![]()
The Min summary function shows the minimum value from the underlying values in the Values area. The result is the same as using the MIN function on the worksheet to calculate the minimum of the values.
In the screen shot below, you can see the source data for a small pivot table, and the minimum quantity, using the worksheet's MIN function, is 8.

With a pivot table, you can quickly see the minimum for each product that was sold, and the grand total -- 8 -- which matches the worksheet minimum.
In both the worksheet and the pivot table, the blank cell is ignored
when calculating the minimum amount.
The Product summary function shows the result of multiplying all the underlying values in the Values area. The result is the same as using the PRODUCT function on the worksheet to calculate the product of the values.
I've never had to use the Product summary function in a pivot table, and can't imagine a situation where it would be useful. However, you might have a use for it, and here's how it works.
In the screen shot below, you can see the pivot table source data, with the PRODUCT calculated for each product group. At the bottom of the source data is the overall PRODUCT calculation.

The results of the Product function may be very large numbers and default to a Scientific number format. You can format the numbers as Number format, instead of Scientific format.

The Count Numbers summary function counts all the underlying numbers in the Values area. The result is the same as using the COUNT function on the worksheet. Blank cells, errors, and text are not counted.
In the screen shot below, you can see the source data for a small pivot table, and the count of the numbers in the Qty column (column C). In cell C4, the value of 20 is entered as text, so that cell isn't counted.

In the pivot table shown below, the Qty field has been added twice to the Values area. In column B, the summary function is Count Numbers, and the Grand Total is 7.
In column C, the summary function is Count, which includes
text, so the Grand Total for that column is 8.

Like the STDEV.P and STDEV.S worksheet functions, the StdDevp and StdDev summary functions calculate the standard deviation for the underlying data in the Values area. The standard deviation is a measure of how widely the values vary from the average of the values.
The StdDevP summary function should be used when the entire population is used in the calculation. When a sample of the data is used, not the entire population, then use the StdDev summary function.
In the screen shot below, you can see example pivot table source data, and the STDEV.P worksheet function is calculating the standard deviation for each product type. For the File Folders, there is a large difference between the quantities sold, and the standard deviation is high -- 44.5. For Paper, the difference in quantity is much smaller, and the standard deviation is low -- 4.7.

When the Qty field is added to the pivot table, change the summary calculation to StdDevp.
In the screen shot below, you can see that the standard deviations in the pivot table are the same as those that were calculated on the worksheet.

Note: If the count of items is one, a #DIV/0! error is displayed when using the StdDev summary function, because one is subtracted from the count when calculating the standard deviation.
For the standard deviation, each number is compared to the mean of the numbers. You could calculate the standard deviation on the worksheet, without using the STDEV.P function.

The Var and Varp summary functions work like the VAR.P and VAR.S worksheet functions, to calculate the variance for the underlying data in the Values area, and variance is a measure of how widely the values vary from the average of the values.
When the entire population is used in the calculation, the VarP summary function is used. For a sample of the data, instead of the entire population, use the Var summary function.
In the screen shot below is the example pivot table source data, with the VAR.P worksheet function calculating the variance for each product type. For the File Folders, where there is a wide difference between the two quantities, the variance is large -- 1980.25. For the paper sales, there is a small difference in quantity, and the variance is only 22.22.

To show the variance, when the Qty field is added to the pivot table, change the summary calculation to Varp.

As you can see, the variances shown in the pivot table are the same as those that were calculated on the worksheet.

Note: If the count of items is one, a #DIV/0! error is displayed when using the Var summary function, because one is subtracted from the count when calculating the variance.
For the variance, each number is compared to the mean of the numbers. You could calculate the variance on the worksheet, without the VAR.P function.

In a pivot table you might want to see a count of unique (distinct) items in your data. For example, how many uniqe sales reps are in the East region?
In Excel 2013 and later versions, you can create a pivot table based on the Data Model. In this video, I show the 3 easy steps, and there are written steps on the Count Unique Items page.
If there are error values in the source data, the pivot table will display an error for that data, except as noted below, for Count and Count Nums.
In this example, the Total field contains a #VALUE! error and a #DIV/0 error, one blank cell (E7), and one cell with text (E9).

These two summary functions count the errors, or ignore them. The errors are not shown in the item totals.

For all other Summary Functions, if errors are in the source data field:
In the data, #VALUE! is the first error listed, so it appears in the pivot table.

However, if you sort the data with the latest dates at the top, the #DIV/0! error is first. Then, refresh the pivot table, and it shows the #DIV/0! error.

If subtotals, or row and column totals, are displayed, affected totals and subtotals display the error.
And even though they don't show errors in the item totals, the Count and Count Numbers functions will also display errors in their totals, if both of these conditions are met:
For example, in the screen shot below, an Average for the Price field has been added, and that field contains a #DIV/0! error. As a result:

This macro is similar to the Sum Function Macro, shown further up on this page.
However, instead of clicking a button to run this macro, you select a Summary Function name from a drop down list on the worksheet.
The cell with the drop down list is named FuncSel, as you can see in the NameBox in the screen shot below.

You can get the Excel sample file (Macro Change All Functions) in the download section below.
On another sheet in the sample file, there is a list of Summary functions, and a formula that looks up the numeric value for each function. The cell with the formula is named FuncSelCode.
When the FuncSel cell is changed, the Worksheet_Change code on that sheet runs.
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Me.Range("FuncSel").Address Then
ChangeAllData (wksLists.Range("FuncSelCode").Value)
End If
End Sub
The ChangeAllData procedure runs, using the numeric value in the FuncSelCode cell, and changes all the data fields in the pivot table.
Sub ChangeAllData(lFn As Long) 'changes data fields to selected function On Error GoTo errHandler Dim pt As PivotTable Dim pf As PivotField Dim ws As Worksheet Application.ScreenUpdating = False Set pt = wksPTSales.PivotTables(1) On Error GoTo errHandler pt.ManualUpdate = True For Each pf In pt.DataFields pf.Function = lFn Next pf pt.ManualUpdate = False exitHandler: Set pf = Nothing Set pt = Nothing Application.ScreenUpdating = True Exit Sub errHandler: GoTo exitHandler End Sub
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!
Last updated: February 14, 2026 4:39 PM