Mass Change of Pivot "Values" from Sum to Average

mcgonma

Board Regular
Joined
Nov 2, 2011
Messages
162
Office Version
  1. 365
  2. 2013
Platform
  1. Windows
I have about 65 items in the Values section of my pivot table. They are all calculating "Sum of" but I need them to calculate "Average".
Is there a way to do this in a mass batch or do I have to change each and every item?
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
In the Field List on the right hand side, the values would be showing of Sum of....
Please click on arrow next to that, --->Field Settings---->beneath summarize value field by- change sum to average

(In case the field list is not visible, please right click on the pivot table, then click Show field list)
 
Upvote 0
In the Field List on the right hand side, the values would be showing of Sum of....
Please click on arrow next to that, --->Field Settings---->beneath summarize value field by- change sum to average

(In case the field list is not visible, please right click on the pivot table, then click Show field list)
My question is do i have to do each one individually or is there a way to change them all as a group?
 
Upvote 0
Select a cell somewhere in the pivot table, then run this code:

VBA Code:
Public Sub SetDataFieldsToAverage()
   With Selection.PivotTable
      .ManualUpdate = True
      Dim ptf As PivotField
      For Each ptf In .DataFields
         ptf.Function = xlAverage
      Next ptf
      .ManualUpdate = False
   End With
End Sub
 
Upvote 0
Also, it sounds like your source data is probably not well set up for a pivot table. ;)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top