Forum Discussion
Anonymous
7 years agoNot applicable
Creating a Rolling 12 months using Month Column
Hi Community, I have to create measure for calculating a rolling 12 months for Sales. I don't have date column but i have month colum(like 1,2,3 ..12) . How can i acheive it. Please help. ...
- Anonymous7 years agoI have created a calender table and created a column order using ranx function. below is the working DAX.12M Rolling YTD = IF (HASONEVALUE ( 'Calendar'[YearMonthNo] ),CALCULATE (SUM( 'NA Daily'[Total Sales] ),FILTER (ALL ( 'NA Daily'[Order] ),'NA Daily'[Order]>= SELECTEDVALUE ( 'Calendar'[Order_Calendar] ) - 11&&'NA Daily'[Order] <= SELECTEDVALUE ( 'Calendar'[Order_Calendar] ))),CALCULATE ( ( 'NA Daily'[Total Sales YTD] ) ))
NickolajJessen
7 years agoSolution Sage
If you have Year and month, you can use the function 'DATE'
Date = DATE(Tabel3[Year];[Month];1)
When you have your date column, you can use this link for the rest
https://community.powerbi.com/t5/Desktop/Trailing-12-or-Rolling-12-month-sum/td-p/164419
https://community.powerbi.com/t5/Desktop/Trailing-12-or-Rolling-12-month-sum/td-p/164419
v-cherch-msft
7 years agoMicrosoft Employee
Hi Anonymous
You may try with below measure. Attached the sample file. If it is not your case, please share some sample data.
Measure =
CALCULATE (
SUM ( Data[Sales] ),
FILTER (
ALL ( 'Data' ),
'Data'[YearMonth]
>= MAX ( Data[YearMonth] ) - 11
&& 'Data'[YearMonth] <= MAX ( 'Data'[YearMonth] )
)
)
Regards,
Cherie
- Anonymous7 years agoNot applicableI have created a calender table and created a column order using ranx function. below is the working DAX.12M Rolling YTD = IF (HASONEVALUE ( 'Calendar'[YearMonthNo] ),CALCULATE (SUM( 'NA Daily'[Total Sales] ),FILTER (ALL ( 'NA Daily'[Order] ),'NA Daily'[Order]>= SELECTEDVALUE ( 'Calendar'[Order_Calendar] ) - 11&&'NA Daily'[Order] <= SELECTEDVALUE ( 'Calendar'[Order_Calendar] ))),CALCULATE ( ( 'NA Daily'[Total Sales YTD] ) ))