Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hello,
I need to calculate ending balance depending on filter selections in the report.
I found a way to get the desired result but it takes too long...
I add pbx file here: https://1drv.ms/u/s!AjCQWBzIRUrlwVraSjUjhGqOpTri?e=vqDO3G
Any ideas how could I improve my measure?
Thanks!
Solved! Go to Solution.
Hi @193
You can use the following code:
Measure = CALCULATE([BS],FILTER(ALL(GL),GL[Acc]=MAX(GL[Acc])&&[Index]<=MAX(GL[Index])))
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
The filter on the high granularity index column is the reason for the slowness. If the running total won't change with slicers, etc., it would be good to pre-calculate it in your query. The new WINDOW function may be a good approach too. However, below is a measure expression that is much faster. Please try it and report back. It calculates the running total from a day standpoint and then just subtracts any index values that came later on same day (if any). Note that I also used the Date column from your Date table in the visual, instead of the one from the GL table.
End_bal 2 =
var thisindex = max(GL[Index])
var maxdate = MAX('Date'[Date])
VAR IndexValues = CALCULATETABLE(DISTINCT(GL[Index]), ALL(GL), VALUES(GL[Acc]), 'Date'[Date] = maxdate)
var FilteredIndexValues = FILTER(IndexValues, GL[Index] > thisindex)
VAR DayRT =
CALCULATE (
[BS],
ALL(gl), VALUES(GL[Acc]),
REMOVEFILTERS('Date'),
'Date'[Date] <= maxdate
)
VAR Subtract =
CALCULATE (
[BS],
ALL(gl), VALUES(GL[Acc]),
GL[Index] in FilteredIndexValues
)
RETURN
DayRT - Subtract
Pat
The filter on the high granularity index column is the reason for the slowness. If the running total won't change with slicers, etc., it would be good to pre-calculate it in your query. The new WINDOW function may be a good approach too. However, below is a measure expression that is much faster. Please try it and report back. It calculates the running total from a day standpoint and then just subtracts any index values that came later on same day (if any). Note that I also used the Date column from your Date table in the visual, instead of the one from the GL table.
End_bal 2 =
var thisindex = max(GL[Index])
var maxdate = MAX('Date'[Date])
VAR IndexValues = CALCULATETABLE(DISTINCT(GL[Index]), ALL(GL), VALUES(GL[Acc]), 'Date'[Date] = maxdate)
var FilteredIndexValues = FILTER(IndexValues, GL[Index] > thisindex)
VAR DayRT =
CALCULATE (
[BS],
ALL(gl), VALUES(GL[Acc]),
REMOVEFILTERS('Date'),
'Date'[Date] <= maxdate
)
VAR Subtract =
CALCULATE (
[BS],
ALL(gl), VALUES(GL[Acc]),
GL[Index] in FilteredIndexValues
)
RETURN
DayRT - Subtract
Pat
There is no file there.
Hi @193
You can use the following code:
Measure = CALCULATE([BS],FILTER(ALL(GL),GL[Acc]=MAX(GL[Acc])&&[Index]<=MAX(GL[Index])))
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!