Forum Discussion
Moving Average
- Anonymous6 years ago
Hi lt79_Pax
You may refer to the blog from this link: https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/
It may help you to have a deeper understanding in filter context and row context.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi lt79_Pax
I build a Sales table to have a test.
Firstly I test your Formula.
But the last value in result is incorrect, the right answer should be 4740/31 = 152.90:
You can try my measure.
Measure =
AVERAGEX (FILTER(ALL( 'Date'),'Date'[Date]<=MAX('Date'[Date])), [ Sales Amount])Result:
Max('Date'[Date]) will return to the Date value in this row. For example, the date value in this row is 2011/12/29, so
FILTER(ALL( 'Date'),'Date'[Date]<=MAX('Date'[Date])) will return to a table the date <= 2011/12/29, and then caluclate the average.
For more info to the Function used in dax: Averagex Max Filter
You can download the pbix file from this link: Moving Average
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Rico,
Thank you for resonding. This is interesting since the initial expressions I provided came directly from 'The Definitive Guide to DAX' book. I was actually more interested in the back end process of how the expressions were allowing the average to move and how and where the contexts, filter or row, were taking place in these processes.
Thank you for the update.
- Anonymous6 years agoNot applicable
Hi lt79_Pax
You may refer to the blog from this link: https://www.sqlbi.com/articles/row-context-and-filter-context-in-dax/
It may help you to have a deeper understanding in filter context and row context.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.