Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
Sign up nowGet Fabric certified for FREE! Don't miss your chance! Learn more
Hi
I have a table and a measure is present to calculate moving average. I have a date slicer present too. Moving average of mine is for previous 3 weeks. So whn any date range is selected, the data of previous weeks is taken as 0 by the measure. This makes first 2 weeks displayed moving average not what it should be.
Table
Week Value
1 12
2 3
3 5
4 7
5 9
6 1
Moving avg for week:
1 - 12/3=4
2 - (12+3)/3=5
3 - (12+3+5)/3=6.67
4 - (3+5+7)/3=5
So on...
This is what I required as there is no data before week 1
But if I select date slicer from week 3 to week 6
I get:
Week 3 - 5/3=1.67 whereas I want it to take week 1 and week 2 in consideration too.
I want the average to be 6.67 whereas getting 1.67
Can this be achieved and if yes, thn how?
Thanks
Solved! Go to Solution.
Moving Average= CALCULATE( AVERAGEX( lineDataClosed, SUM(lineDataClosed[Closed Count])/3 ), ALL(lineDataClosed), DATESINPERIOD( lineDataClosed[Week], LASTDATE(lineDataClosed[Week]), -21, DAY ) )
Try this and let me know the result.
Have a look at the DAX statement you have used to calculate your measures. Dax Statements are context sensitive, meaning that they change their results based on slicers.
You might need to make use of an ALL() style function to tell it to consider all of the information. Its going to be tough to give you a more direct solution because ALL() will avoid every slicer, which you might not want. So you might need to use ALLEXCEPT().
@Anonymous
Moving Average= CALCULATE(AVERAGEX(lineDataClosed,sum(lineDataClosed[Closed Count])/3),DATESINPERIOD(lineDataClosed[Week],LASTDATE(lineDataClosed[Week]),-21,DAY))
This expression is giving me the result as per now. Where do I need to place All() or ALLEXCEPT() to get the desired result?
Thanks
Moving Average= CALCULATE( AVERAGEX( lineDataClosed, SUM(lineDataClosed[Closed Count])/3 ), ALL(lineDataClosed), DATESINPERIOD( lineDataClosed[Week], LASTDATE(lineDataClosed[Week]), -21, DAY ) )
Try this and let me know the result.
@Anonymous
Thanks a lot
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 63 | |
| 62 | |
| 42 | |
| 20 | |
| 18 |