Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Performance issue to find Rolling52WeekAverage from the Measure value using by (SUMX & AVERAGEX)

Hi,

 

I am using the following two DAX formulas to find an average of Rolling52Weeks from the Measure value, the results are getting correctly but performance is very slow.  I just filtering the prior 52 weeks from the calendar and applying into SUMX/ AVERAGEX in order to get a result. 

 

Can anyone please help me if there is any way to replace the SUMX/ AVERAGEX for the below scenarios or can please confirm if I made any logical mistaken on the below DAX.

 

Appreciate if you join with me to get resolved.

 

Rolling52WeekAverage:=

var Filtervalue =
FILTER(ALL(CalendarWeekly),AND(CalendarWeekly[CalendarWeeklySkey] <=max(CalendarWeekly[CalendarWeeklySkey]),CalendarWeekly[FiscalWeekCloseDt] > max(CalendarWeekly[FiscalWeekCloseDt]) - 364 && Fact[Average_FlagNew] <> 3))

var Tempcnt =
COUNTROWS ( Filtervalue )

var rd = SUMX(Filtervalue ,Fact[Measure Value])

return DIVIDE(rd, Tempcnt )

 

Rolling52WeekAverage:=

var Filtervalue =
FILTER(ALL(CalendarWeekly),AND(CalendarWeekly[CalendarWeeklySkey] <=max(CalendarWeekly[CalendarWeeklySkey]),CalendarWeekly[FiscalWeekCloseDt] > max(CalendarWeekly[FiscalWeekCloseDt]) - 364 && Fact[Average_FlagNew] <> 3))

return AVERAGEX(FILTER(Filtervalue,IF(Fact[Average_FlagNew] <> 3 ,1)),Fact[Measure Value])

 

Regards,

 

Raj

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@Anonymous 

I am not sure if the SUMX or AVERAGEX causes the issue, check your data model with best practices https://powerbi.microsoft.com/en-us/blog/best-practice-rules-to-improve-your-models-performance/

 

Check the following modified measure.

Rolling52WeekAverage = 
var _skey = _CalendarWeekly[CalendarWeeklySkey]
var _close = _CalendarWeekly[FiscalWeekCloseDt]- 364
var Filtervalue =
    FILTER(
        ALL(CalendarWeekly[CalendarWeeklySkey],CalendarWeekly[FiscalWeekCloseDt]),
        CalendarWeekly[CalendarWeeklySkey] <=_skey &&
        CalendarWeekly[FiscalWeekCloseDt] > _close  && 
        [Average_FlagNew] <> 3
    )

var Tempcnt = COUNTROWS ( Filtervalue )
var rd = SUMX(Filtervalue ,[Measure Value])
    return 
    DIVIDE(rd, Tempcnt )



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@Anonymous 

I am not sure if the SUMX or AVERAGEX causes the issue, check your data model with best practices https://powerbi.microsoft.com/en-us/blog/best-practice-rules-to-improve-your-models-performance/

 

Check the following modified measure.

Rolling52WeekAverage = 
var _skey = _CalendarWeekly[CalendarWeeklySkey]
var _close = _CalendarWeekly[FiscalWeekCloseDt]- 364
var Filtervalue =
    FILTER(
        ALL(CalendarWeekly[CalendarWeeklySkey],CalendarWeekly[FiscalWeekCloseDt]),
        CalendarWeekly[CalendarWeeklySkey] <=_skey &&
        CalendarWeekly[FiscalWeekCloseDt] > _close  && 
        [Average_FlagNew] <> 3
    )

var Tempcnt = COUNTROWS ( Filtervalue )
var rd = SUMX(Filtervalue ,[Measure Value])
    return 
    DIVIDE(rd, Tempcnt )



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Your DAX logic works fine and it  is faster than earlier logic. 

 

Thank you so much Fowmy!!

 

Regards,

 

Rajkumar

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors