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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

How to improve a slow DAX query using FILTER(ALLSELECTED()) for running total

Hi,

 

I'm new in DAX and I‘ve got a performance issue with this formula:

 

Value running total = 
CALCULATE(
SUM(Facts[Value]);
FILTER(ALLSELECTED(Facts);
Facts[Hour]<=MAX(Facts[Hour])
))

 

The response time is around 45 seconds. I want to have a running total by hours (over the current day) with a dependency of 3 slicers.

 

My report is based on only one table containing 9 columns and around 300'000 records. I tried to use one fact table and multiple dimension tables, but the performance didn't increase.

 

Is there another / better way to solve this?

 

Thanks!

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Anonymous,

 

Try to change your measure to only get data from the Hour column.

 

Value running total = 
CALCULATE(
SUM(Facts[Value]);
FILTER(ALLSELECTED(Facts[Hour]);
Facts[Hour]<=MAX(Facts[Hour])
))

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @Anonymous,

 

Try to change your measure to only get data from the Hour column.

 

Value running total = 
CALCULATE(
SUM(Facts[Value]);
FILTER(ALLSELECTED(Facts[Hour]);
Facts[Hour]<=MAX(Facts[Hour])
))

Regards,

MFelix


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português





Anonymous
Not applicable

Hi @MFelix 

I am developing a measure to calculate running total of a measure which is very slow.

Base Measue = Var Hours = Calculate(Sum(FactTable[Hours])
Var Cost = Calculate(Sum(FactTable[Cost]),DimA[Attribute1] = "Services")

Return

Divide(Cost,Hours)

 

I have to create a Running Total of Hours  when its sorted from Desc to Asc by BaseMeasure

MainMeasure = Var CurrentRatio = BaseMeasure

Return

Calculate(Sum(FactTable[Hours]),Filter(ALLSELECTED(FactTable),BaseMeasure >= CurrentRatio))

 

This measure is very slow.

Please suggest some improvement points. Using this MainMeasure I have to develop around 10-15 more calculations.

Anonymous
Not applicable

Hi @MFelix

 

Very nice, it works - thank you!

 

I thought I have to use the entire table in ALLSELECTED() cause of the slicers.

 

Regards

Swiss_BI

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.