Forum Discussion
How to get average across all dates using rolling average?
Hi PowerUser2000 ,
So glad to hear that it worked. You're right though using AVERAGEX over VALUES(Dates[Date]) for a rolling measure can introduce performance overhead, especially if your date table is large or you're working with a lot of rows in your fact table.
A few ways to optimize it.
Limit the date range in visuals or model. If possible, restrict the date range using a report-level or page-level filter. For example, only load or display the past 12–24 months instead of many years. This reduces how many rows AVERAGEX has to iterate over.
Use a summarized Date table. Instead of using VALUES(Dates[Date]) which includes all dates, you can use a virtual table with only the dates that matter, like using bellow.
MonthlyAvg_Rolling33DayDistinctCount = AVERAGEX(FILTER(VALUES(Dates[Date]),
Dates[Date] <= MAX(Dates[Date]) && Dates[Date] >= MAX(Dates[Date]) - 32),
[Rolling33DayDistinctCount])
This narrows the iteration to only 33 dates, drastically improving performance and the result is still a valid average of the 33-day rolling counts.
Pre-calculate in a summary table (if you can). If your data volume is really high and the measure is still slow, you might consider creating a pre-aggregated summary table (like daily distinct counts) using Power Query or DAX summary tables. Then build your monthly average on top of that lightweight table.
The above steps will resolve your issue.
Regards,
Akhil.
Hi PowerUser2000 ,
Just checking in to see if the optimization tips helped improve performance. If you’ve had a chance to try them out, I’d love to hear how it went. If everything’s working fine now, we’ll consider this one resolved. Otherwise, feel free to share more details we’re happy to help further.
Regards,
Akhil.
- Anonymous1 year agoNot applicable
Hi PowerUser2000 ,
Hope you're doing well. Just wanted to follow up once more in case you had a chance to test the optimization suggestions we discussed earlier. We totally understand things get busy, so no rush but if you're still seeing performance issues or need further tweaks, feel free to drop a note. Happy to jump in and assist further.
Thanks again,
Akhil - PowerUser20001 year ago
Helper I
This is still slow in the report. The dataset consists of millions of rows.