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

Overtime calculation

I am trying to calculate weekly over time of total Duration.

The formula(s) that I am currently using are:1.png

TotalHours = SUM(HoursData[Duration])
Overtime = IF([TotalHours] > 37.5, IF(([TotalHours]-37.5)>6.5, 6.5, ([TotalHours]-37.5)), 0)

While using the Overtime DAX Formula, it does calculate properly on the row level but when it comes to Matrix Total, its always showing 6.5

Any way to fix this please?

Thanks

17 REPLIES 17
Padycosmos
Solution Sage
Solution Sage

Hope this helps:

Overtime =SWITCH(TRUE(),[TotalHours]-37.5>6.5, 6.5,[TotalHours]-37.5)<=6.5, [TotalHours]-37.5,0)

Padycosmos
Solution Sage
Solution Sage

Hope this helps:

Overtime =SWITCH(TRUE(),[TotalHours]-37.5>6.5, 6.5,[TotalHours]-37.5)<=6.5, [TotalHours]-37.5,0)

Hope this helps:

Overtime =SWITCH(TRUE(),[TotalHours]-37.5>6.5, 6.5,[TotalHours]-37.5)<=6.5, [TotalHours]-37.5<=0,0)

Anonymous
Not applicable

Hi @Padycosmos - It says there is a syntax error

Sorry about that, here's the corrected one

Hope this helps:

Overtime =SWITCH(TRUE(),[TotalHours]-37.5>6.5, 6.5,[TotalHours]-37.5)<=6.5,[TotalHours]-37.5, [TotalHours]-37.5<=0,0)

Anonymous
Not applicable

Its still not calculating on the row level of the matrix .. 

 

If the data is not sensitive, could you please share the pbix file?

 

Please create a calculated column instead of Measure

Anonymous
Not applicable

Even with the created column it says syntax error

Really sorry, there was an extra bracket. I have removed it now. Please try again

Overtime =SWITCH(TRUE(),[TotalHours]-37.5>6.5, 6.5,[TotalHours]-37.5<=6.5,[TotalHours]-37.5, [TotalHours]-37.5<=0,0)

Anonymous
Not applicable

It still didnt work - I am trying to share the dataset but couldnt find the option to do so. I am sorry

You can put it in google drive and paste the link here

Hope this edited one helps:

Overtime =SWITCH(TRUE(),[TotalHours]-37.5>6.5, 6.5,[TotalHours]-37.5)<=6.5, [TotalHours]-37.5<=0,0)

Padycosmos
Solution Sage
Solution Sage

Hope this helps:

Overtime =SWITCH(TRUE(),[TotalHours]-37.5>6.5, 6.5,[TotalHours]-37.5)<=6.5, [TotalHours]-37.5,0)

 

MarkLaf
Super User
Super User

I think something like this should work.

Overtime=
SUMX(
    HoursData,
    MAX( MIN( SUM( HoursData[Duration] ) - 37.5, 6.5 ), 0 )
)

Alternatively, this is the kind of thing that you could tackle with a calculated column.

Anonymous
Not applicable

Hi @MarkLaf - The proposed solution did not work properly. It gave different numbers than to what I am expecting. But thank you

Oops. I shouldn't have had SUM in there. I think this should do it. If not, it would be helpful to provide some test data and more info on your model.

Overtime=
SUMX(
    HoursData,
    MAX( MIN( HoursData[Duration] - 37.5, 6.5 ), 0 )
)

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.