Forum Discussion
Issue With Rolling 3 Month Average
Hi newguy
Please try
Net Revenue R3M :=
VAR NumOfMonths = 3
VAR LastSelectedDate =
MAX ( D_DATE[Calendar_Date] )
VAR Period =
DATESINPERIOD ( D_DATE[Calendar_Date], LastSelectedDate, - NumOfMonths, MONTH )
VAR Result =
CALCULATE (
AVERAGEX (
SUMMARIZE ( D_DATE, D_DATE[Month Year], D_DATE[Year] ),
[Total Net Revenue by DOS]
),
Period
)
RETURN
Result- newguy4 years agoNew Member
tamerj1 I tried using the SUMMARIZE function but ended up with the same result. I'm wondering if it an issue with the underlying data model or something. Is there potentially a different way to get the same rolling average by month result?
- tamerj14 years ago
Community Champion
I don't think anything wrong with the model. Please try
Net Revenue R3M := AVERAGEX ( SUMMARIZE ( D_DATE, D_DATE[Month Year], D_DATE[Year] ), CALCULATE ( VAR NumOfMonths = 3 VAR LastSelectedDate = MAX ( D_DATE[Calendar_Date] ) VAR Period = DATESINPERIOD ( D_DATE[Calendar_Date], LastSelectedDate, - NumOfMonths, MONTH ) VAR Result = CALCULATE ( AVERAGEX ( VALUES ( D_DATE[Month Year] ), [Total Net Revenue by DOS] ), Period ) RETURN Result ) )- newguy4 years agoNew Member
tamerj1 Same issue unfortunately. Let me make sure I am using the correct date fields in your example. Here are some of my date table fields and an example value from the table:
*Calendar_Date = 1/1/2022 12:00:00 AM
*Calendar_Month = 1
*Calendar_Year = 2022
*Month_Year = January 2022
*Year_Month = 2022-01
I tried switching the SUMMARIZE function to be
SUMMARIZE(D_DATE,D_DATE[Calendar_Month], D_DATE[Calendar_Year])
as well and didnt have any luck.