Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel pivot table - average of calculated sums

I'm sure this is simple, but how do I get a pivot table to display an average for a calculated sum of fields? In the simplified example, I've filtered out fund x1, and the pivot table is showing the sums of the remaining funds per person. Now how do I get an average by person (so, manually calculated, 3300/3)?

I tried using a calculated field, but cannot figure out how it will work because the denominator will change based on how many people will have the funds I'm filtering on. If I use the averaging inside the calculated field it goes back to averaging the funds.

I tried putting the calculation outside the pivot table, and this works, but of course as I filter, my calculated field is no longer adjacent to the pivot table data, instead just floating off on the worksheet by itself.

TIA.

example

Per request here is the field list - if I try adding an "average of amount" to the value box it averages the fund amounts, instead of the fund amount per person. :

enter image description here

like image 808
Sparky McSparky Avatar asked Feb 21 '14 16:02

Sparky McSparky


People also ask

Can you have sum and average in a pivot table?

You can even show the Average in Pivot Table instead of Sum! The Summarize Values By option allows you to choose a type of calculation (Sum, Count, Average, Max, Min, Count Numbers Product, StdDev, StdDevp, Var, Varp) to summarize data from the selected field.

How does Excel calculate average in pivot table?

The Grand Total average in the pivot table is adding up all of the cells in the quantity column of the data set and dividing it by the total number of orders.

Can pivot table do weighted average?

In a PivotTable, you can calculate a weighted average for numeric fields by adding a calculated field. A calculated field is a column that you add to a PivotTable that contains a formula. The formula can use the fields in the PivotTable as well as other mathematical operators.


1 Answers

Here is working solution:

Firstly you should install or enable Power Pivot. Quoting Microsoft:

Power Pivot is an Excel add-in you can use to perform powerful data analysis and create sophisticated data models.

https://support.office.com/en-us/article/Power-Pivot-Powerful-data-analysis-and-data-modeling-in-Excel-a9c2c6e2-cc49-4976-a7d7-40896795d045?ui=en-US&rs=en-US&ad=US

In newer Excel versions Power Pivot is already installed and you can enable it by going to:

File > Options > Advanced > Data > Enable Data Analysis add-ins: Power Pivot, Power View, and Power Map

Alright, so you have Power Pivot now and you can see Power Pivot tab. Please follow the steps below:

  1. Select your data and click add to “data model” icon on Power Pivot tab.
  2. In Power Pivot window add column which will count distinct number of persons in the data. =DISTINCTCOUNT([person]) name it for example “DistPersNo”. This is crucial step – Power Pivot enables you to count unique values in selected column.
  3. Add another column with formula =[amount]/[DistPersNo] name it “PersonAverages”.
  4. In Power Pivot window click PivotTable and add new pivot table to your worksheet.
  5. In Pivot Table add 'persons' to rows and 'amount' to values. Now, if you add 'PersonAverages' to values (sum of it) and filter out fund 'x1' you will achieve desired result i.e. value of 1100.

Hope that helps.

like image 67
TomJohnRiddle Avatar answered Oct 12 '22 15:10

TomJohnRiddle