January 31, 2020
Hi,
Am trying for weeks now to add an average in a pivot table. It seems so obvious, but somehow I miss out somewhere.
To test different solutions I made a small testfile with a few data in a dataset. Loaded this into PowerQuery, transformed a bit and loaded in into Excel. Then I created a pivottable with the product as row, the month as column and the sales as values. So far it works. At the end of every column and row there is a Grand total. Perfect.
Now I want to add an extra column as an average of a product over the total of the months. Not every month an average (like most solutions do) but only one figure after the grand total stating the average sale of a product in this yeqr. Can't be too hard....
Probably I need to use a measurement for this, but where and how...?
Hopefully anyone can give me a clue. I am a novice Power Query and Pivot user.
Thanks!
Jeroen
(the testfile is added to this topic)
July 16, 2010
Hi Jeroen,
Unfortunately, regular PivotTables and Power Pivot PivotTables won't show the months broken out for one aggregation method (sum) and not another (average). It's either all or none.
I recommend you add another PivotTable beside with the average sales not broken out into months, and then just hide the row labels column of that PivotTable so it appears to be part of the original PivotTable. You'll need to take care that they remain in sync with each other in terms of the row labels.
Mynda
January 31, 2020
Hi Mynda,
Thanks for your quick reply. That's really amazing.
I must study on this new view. I thought it would be easy and that I just lacked the knowledge. I need to get back to the philosophy of things.
Hmm, if I come up with a solution I will post and share this.
PS: I do love your pace in the course videos while I am doing my training exercises in the gym (that's the way I study :-))
Thanks, Jeroen
Trusted Members
Moderators
November 1, 2018
What you could do with a Power Pivot PT is to create a measure to average the monthly totals (eg =AVERAGEX(values(Table_after_Power_Query[month]),[TotalSales])), then create a set based on columns so that you only show that average calculation for the total column, not the individual month names.
Answers Post
Trusted Members
Moderators
November 1, 2018
January 31, 2020
Wow Velouria, this did the job!
I added my table to the datamodel.
Entered the measurement in the datamodel as AVERAGEX(VALUES(columname);CALCULATE(SUM(columname))) and this gave the filtered average which I wanted.
It seems to me that entering a measurement in the datamodel works better then trying to make a measurement in Power Pivot (Office365), however I do not know how to "name" (label) the measurement, since it is no longer accessible in Power Pivot where you can add a name and description, which is not available in the datamodel.
In PowerPivot you can then easily create a set and remove all columns I do not want. With the correct result!
I do have some challenges now to make the view nice, because the set has blocked some cells in te result where I want to overwrite the labels and use other fonts and colors to make a clean and esthetic dashboard.
Thanks again, and I am going to find a way to give a name to my measurement and to add some esthetics to the result.
Kind regards, Jeroen
1 Guest(s)