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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
StephenCudd
Regular Visitor

Calculate sum on any given day for data identified by range

Hello Power BI experts, I am new here although I have been using Power BI for a few years. I am struggling with what seems a relatively simple problem but is driving me nuts. Hopefully somebody can suggest a solution.

 

I have a fact table of service data and a date dimension. For this example I have eliminated the join between the tables but previously they were joined on planned service date. So no problem summarising planned service hours by day. My objective in this case is to determine, for any day in the past, how many planned service hours were overdue at that moment in time. On the fact table I have created two calculated columns that determine the date at which the planned service became overdue and the date at which it was completed. My summary therefore, is the number of planned service hours on any given day for which the "start of overdue date" has passed and the "end of overdue date" hasn't been reached.

 

I created a measure on my dates dimension as follows:

 

Overdue tracker = calculate(sum(service_hours), filter(fact_table, start_of_overdue_date <= selectedvalue(measuredate) && end_of_overdue_date >= selectedvalue(measuredate))))

 

It works to some degree however it takes a very long time to recalculate (up to 10 minutes) which suggests it is very inefficent and makes it difficult to assess accuracy. I want to retain the option to filter and slice the output so a calculated column or table doesn't really answer the problem.

 

Any suggestions would be greatly appreciated.

 

2 REPLIES 2
Anonymous
Not applicable

Hi @StephenCudd ,

 

Your measure looks fine and not complicate at all. What data source are you using and how many data you have?

And if it's about calculation, better to show some sample data to us.

 

Best Regards,

Jay

 

Community Support Team _ Jay Wang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @Anonymous , thanks for responding. The data I am using, in simple terms, is:

 

Fact Table (2.5 million rows)

RecordNo - 1,2,3,4,5,etc

Start_Of_Overdue_Date - 01/01/2000, etc

End_of_overdue_date - 31/12/2000 etc

Service_hours - 5.1, 3.2, 1.5, etc

 

Date Dimension (18,250 rows, each date from 01/01/2000 to 31/12/2050)

MeasureDate

 

One thing that has become apparent is that measures seem to be evaluated for the whole dataset each time rather than just for what is being visualised. I have partly solved the problem by wrapping the calc in an if statement to limit the calculation just to the last year.

 

Overdue tracker = if(selectedvalue(measuredate) <= today() && selectedvalue(measuredate) >= (today() - 365), calculate(sum(service_hours), filter(fact_table, start_of_overdue_date <= selectedvalue(measuredate) && end_of_overdue_date >= selectedvalue(measuredate)))), 0)

 

This has made visualisation performance acceptable however I was previously under the impression that measures are only evaluated for the filtered and sliced data being represented. In other words, without the IF statement, if I filter to just show data for the last year the measure will still calculate for all 18,250 rows on my date table. Is this correct?

 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Solution Authors
Top Kudoed Authors