Forum Discussion
yuhkao
Microsoft Employee
6 years agoRolling 3 month
Hi I would like to have rolling data for calculation of [measure] for 3 months. please help me to create it. thanks date format is in YYYYMM format, which is text in data type now. for ...
MFelix
Super User
6 years agoHi yuhkao ,
Follow the steps below:
- Add a Endofmonth column in query editor or DAX:
Power Query:
Date.EndOfMonth(#date(
Number.FromText
(Text.Start(Number.ToText([Date]),4)),Number.FromText(Text.End(Number.ToText([Date]),2)),1))
DAX:
Month_End_DAX = EOMONTH(DATE(LEFT('Table'[Date];4);RIGHT('Table'[Date];2);1);0)
Now add the following measure to your model:
Rolling 3 month = CALCULATE(SUM('Table'[Data]);DATESINPERIOD('Table'[Month_End];MAX('Table'[Month_End]);-3;MONTH) ; ALLSELECTED('Table'[Data]))
Should return expected result.