Hello
Thanks to @deltaselect I have a rolling average based on a slicer to make the number of months to average dynamic. I want to compare the previous period rolling average to get a variance
I’ve tried using the DateAdd as below but that is returning 125.33 when it should be 92. Not sure why this isn’t working …
Av. monthly sales (onboard adjusted) Prv Period =
VAR PeriodstoRoll = [Rolling Months]
RETURN
CALCULATE( [Av.monthly sales (onboard adjusted)],DATEADD(DateT[Date],PeriodstoRoll*-1,MONTH))
Hereby a solution, which gives the previous month Average monthly sales (onboard adjusted). When the Rolling Months are 0 or 1 (being not yet or the first month on board), the result is set to 0.
Could you confirm that this is the calculation you are looking for ? (see also attached PBIX, measure and outcome below:
Thanks for your help Jan
Its not quite what I’m looking for. I’m trying to compare the dynamic rolling average with the rolling average for the same previous period
eg
if I’m looking at Dec. Rolling Months = 3
Av. monthly sales (onboard adjusted) = Sum(Dec, Nov, Oct)/3
Prv Period Av. monthly sales (onboard adjusted) = Sum( Sept, Aug, July) / 3
NB The divisor is adjusted as previously
Still looking at Dec if Rolling Months = 6
Av. monthly sales (onboard adjusted) = Sum(Dec, Nov, Oct,Sept,Aug,July)/6
Prv Period Av. monthly sales (onboard adjusted) = Sum( June, May, April, Mar, Feb,Jan) / 6
NB The divisor is adjusted as previously
Please receive hereby an adjustment, which hopefully meets your requirement. Let me know your thoughts.
The measure results to 0, whereby the rolling months period exceeds the starting months (Jan, Feb and Mar are 0, when rolling months periods is 3 ), therefore it needs “[Prev month rolling months]”