cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Measure loads slowly

Hi Community,

 

I built a power bi that includes a measure for a rolling 5-day average. This rolling average can only include volume from non-weekends and non-holidays. I've gotten it to calculate correctly using the dax below, but it takes a while to run. Can anyone help me write this more efficiently?

 

Also, the business days index ranks business days in ascending order from today. In other words, the most recent business day is ranked 1 (today). The second most recent is ranked 2 (yesterday). Days in the date table that aren't business days are left blank.  

 

 

Rolling 5 day average_business days only = 

VAR TopRank = min(DateDim[Business days index])
Var RankUL = TopRank+5
VAR RollingSum = 
    sumx(
        filter(
            ALLSELECTED('Visit Details'),
                'Visit Details'[Business day index] < RankUL &&
                'Visit Details'[Business day index] >= TopRank),
        [Total Visits])    
Return Divide(RollingSum,5)

 

 

Thank you in advance for your help!

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User IV
Super User IV

Re: Measure loads slowly

@738o51 Maybe try:

Rolling 5 day average_business days only = 
VAR TopRank = min(DateDim[Business days index])
Var RankUL = TopRank+5
VAR RollingSum = 
    CALCULATE
        SUM([Total Visits]),
        filter(
            ALLSELECTED('Visit Details'),
                'Visit Details'[Business day index] < RankUL &&
                'Visit Details'[Business day index] >= TopRank),
    )  
Return Divide(RollingSum,5)

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Highlighted
Super User IV
Super User IV

Re: Measure loads slowly

@738o51 Maybe try:

Rolling 5 day average_business days only = 
VAR TopRank = min(DateDim[Business days index])
Var RankUL = TopRank+5
VAR RollingSum = 
    CALCULATE
        SUM([Total Visits]),
        filter(
            ALLSELECTED('Visit Details'),
                'Visit Details'[Business day index] < RankUL &&
                'Visit Details'[Business day index] >= TopRank),
    )  
Return Divide(RollingSum,5)

---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

Highlighted
Helper II
Helper II

Re: Measure loads slowly

@Greg_Deckler  Thank you!!

Highlighted
Super User IV
Super User IV

Re: Measure loads slowly

@738o51 - Curious, how much did that speed things up?


---------------------------------------

@ me in replies or I'll lose your thread!!!

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Helper II
Helper II

Re: Measure loads slowly

My data set is pretty large so the change was significant. I went from about 2 minutes to load the graph to about 1 second. Thanks again!

@Greg_Deckler 

Helpful resources

Announcements
Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

Mark your calendars and join us for our next Power BI Dev Camp!.

Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors