Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I have sales data in which I have sales from year 2012 to current date. What I want to plot on a line graph is past 12 month sales vs past 12 month moving average sales.
I was able to calculate past 12 month sales but got stuck at past 12 month moving average.
By 12 month moving average I mean that for current month (May 201) I should get the average for past 12 months ,i .e., May (2016) to April 2016. Similarly for April 2017 it should be average of sales between April 2016 to march 2017 and so on.
Please help.
Thanks,
Siddhant
Solved! Go to Solution.
To calculate the moving 12 months average, you just need to have the moving 12 months total divide existing months in past 12 months. You can use DATESINPERIOD() to get the past 12 months context.
I assume you already have a YearMonth column in your table. You can try following formula:
Moving Average = CALCULATE ( SUM ( 'Table'[Amount] ) / DISTINCTCOUNT ( 'Table'[YearMonth] ), DATESINPERIOD ( 'Table'[Date], LASTDATE ( 'Table'[Date] ), -12, MONTH ) )
Please also refer to blogs below:
Rolling 12 Months Average in DAX
Regards,
To calculate the moving 12 months average, you just need to have the moving 12 months total divide existing months in past 12 months. You can use DATESINPERIOD() to get the past 12 months context.
I assume you already have a YearMonth column in your table. You can try following formula:
Moving Average = CALCULATE ( SUM ( 'Table'[Amount] ) / DISTINCTCOUNT ( 'Table'[YearMonth] ), DATESINPERIOD ( 'Table'[Date], LASTDATE ( 'Table'[Date] ), -12, MONTH ) )
Please also refer to blogs below:
Rolling 12 Months Average in DAX
Regards,
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
99 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
87 | |
64 |