Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hello, I have found many threads about moving average but they are all based on date filters (e.g. moving average based on a time windows of at least 1 day). In my report I need to implement a moving average based on a specific number of samples (e.g. buffer size of 10 samples) or based on hours (time window of 3 hours).
How is this possible?
Thank you in advance
Solved! Go to Solution.
Hi @marco_2020 ,
You can try the following dax:
Meaure =
VAR currDate =
MAX ( Table[LOAD_END_TIME] )
RETURN
CALCULATE (
AVERAGE ( Table[SHOVEL_TRUCK_DIFFERENCE] ),
FILTER (
ALLSELECTED ( Table ),
[LOAD_END_TIME] <= currDate
&& DATEDIFF ( [LOAD_END_TIME], currDate, SECOND ) <= 1800
)
)
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
I am not sure if I understood your question correctly.
I tried to create a sample pbix file like below, and the below sample is showing last 10 samples moving avg.
Moving avg of last 10 index measure: =
AVERAGEX (
TOPN (
10,
FILTER ( ALL ( Data ), Data[Index] <= MAX ( Data[Index] ) ),
Data[Index], DESC
),
Data[Value]
)
Hello,
really thank you.
My last concern is regarding computing moving average in a dataset over datetime column considering for example last 3 hours as time window. Is this possible?
Thanks
Marco
Hi,
I do not know how your data model looks like, but I think it is possible by using dim-time table for the calculation of 3 hrs segment.
Thank you.
Hi @marco_2020 ,
You can try the following dax:
Meaure =
VAR currDate =
MAX ( Table[LOAD_END_TIME] )
RETURN
CALCULATE (
AVERAGE ( Table[SHOVEL_TRUCK_DIFFERENCE] ),
FILTER (
ALLSELECTED ( Table ),
[LOAD_END_TIME] <= currDate
&& DATEDIFF ( [LOAD_END_TIME], currDate, SECOND ) <= 1800
)
)
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Fabric update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!