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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
New_be
Helper IV
Helper IV

Measure Performance Issue: Running Total

Hi expert!

 

I have a measure performance problem to calculate a running total.


First Measure:

First is, i have a total man days calculation. Function of this measure is to count [Leave Entitlement];
*Leave entitlement consist of: annual leave (AL), Emergency leave (EL) and so on.

  

Total Man days = COUNTA( 'Leave Table'[Leave Entitlement] )
   Capture13.PNG
 
 
Second Measure:
This measure is to calculate running totals of man days or i called cumulative of total man days.
 
Cumulative Total Man Days =
   VAR maxDate = MAX('Calendar'[Date])
   VAR result =
      CALCULATE(
            [Total Man Days],
            FILTER(
                ALL('Calendar'[Date]),
                'Calendar'[Date] <= maxDate
   )
)

RETURN result


What happen when i implemented the second measure inside a visual?
Its worked, but Its load very very very slow. Can someone tell me why?

*In visual below, i take second measure over [date]

Capture14.PNG

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @New_be ,

 

Your formula looks quite simple. You could try to modify the second formula as below and see if there's any improve to the speed.

Cumulative Total Man Days =
   VAR maxDate = MAX('Calendar'[Date])
   var tmp_table = FILTER(ALL('Calendar'[Date]),'Calendar'[Date] <= maxDate)
   VAR result =
      CALCULATE(
            [Total Man Days],
             tmp_table
)

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
AlB
Super User
Super User

@New_be 

Have you used tried the changes I suggested?

Another option would be to use week or month in the axis to reduce the number of calcs

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Not yet because currently im focusing on the other report. After i try your measure, i will let you know. Big thanks @AlB 😊

AlB
Super User
Super User

Hi @New_be 

I don't see any glaring issue with your code.

1) Can you share the pbix by any chance?

2) What are you using in the x-axis of the chart, Calendar[Date]?

3) Why are you using COUNTA instead of COUNT. Try these changes:

      

       Total Man days = COUNT( 'Leave Table'[Leave Entitlement] )

 

Cumulative Total Man Days =
VAR minDate =
    MINX ( ALL ( 'Calendar'[Date] ), 'Calendar'[Date] )
VAR maxDate =
    MAX ( 'Calendar'[Date] )
VAR result =
    CALCULATE (
        [Total Man Days],
        DATESBETWEEN ( 'Calendar'[Date], minDate, maxDate )
    )
RETURN
    result

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Sorry i cannot share my report.
Yupp. I dont see any issue with my code either. For X-axis, i use date.

 

BTW, thanks for for remarks! really appreciate it 😊

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.