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 exmaple
data rolling data
202001 300 300
202002 100 400
202003 700 1100
202004 200 1000
Hi yuhkao ,
This code is a calculated column in DAX in order to have a date column to use on the rolling 3 months.
Month_End_DAX = EOMONTH(DATE(LEFT('Table'[Date];4);RIGHT('Table'[Date];2);1);0)
7 Replies
- MFelix
Super User
Hi 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.