Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
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] )
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]
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
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
Not yet because currently im focusing on the other report. After i try your measure, i will let you know. Big thanks @AlB 😊
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
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 😊
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 45 | |
| 35 | |
| 30 | |
| 15 | |
| 15 |
| User | Count |
|---|---|
| 58 | |
| 56 | |
| 38 | |
| 21 | |
| 21 |