6 Replies Latest reply: Jan 26, 2017 9:37 AM by Sunny Talwar

# Calculating Monthly Variance in Pivot

I have a pivot table in which I'm trying to calculate a yearly average in a column, but having the month as a dimension is throwing it off. An idea for the final output would be like the table below. Any thoughts?

MonthCostYear AverageVariance

Jan

10

21-11
Feb1521-6
Mar2021-1
Apr1521-6
May521-16
Jun452124
Jul30219
Aug2021-1
Sep1521-6
Oct30219
Nov2021-1
Dec25214
• ###### Re: Calculating Monthly Variance in Pivot

May be like this:

CostExpression - Avg(TOTAL Aggr(CostExpression, Month))

Where Replace CostExpression with your expression for Cost

• ###### Re: Calculating Monthly Variance in Pivot

Assuming is it Sum(Cost)

Sum(Cost) - Avg(TOTAL Aggr(Sum(Cost), Month))

• ###### Re: Calculating Monthly Variance in Pivot

Thank you! That worked. What if I wanted to run it as a rolling n-period average?

• ###### Re: Calculating Monthly Variance in Pivot

Can you elaborate with an example?

• ###### Re: Calculating Monthly Variance in Pivot

Yes, so in the same table above, if I wanted the December number to the a three-period average, it would calculate the average of December, November, and October. If I wanted the same calculation for August, it would calculate the average for August, July, and June.

• ###### Re: Calculating Monthly Variance in Pivot

May be like this

CostExpression - RangeAvg(Above(CostExpression, 0, 3))