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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
barbforsman
Resolver I
Resolver I

Overtime Calculation

This question has been asked several times, but I wasn't able to make any of the solutions provided fit my scenario. I have a table with the following data:

 Name, Date Worked, WeekEnding Date, Hours Worked, Work Order

I need to sum the Hours Worked by week by employee to determine overtime.  I have used this formula for HoursPerWeek:

HoursPerWeek = calculate(
SUM(R550618NLK[Hours]),
filter(R550618NLK,R550618NLK[WeekEnding])
)

 

But finding Overtime is challenging me!  I have tried:

OT = if([HoursPerWeek]>40,[HoursPerWeek] - 40,BLANK())

This works when I look at individual employees, but this doesn't sum up correctly in a matrix.

 

I've also tried using my Measure, HoursPerWeek:

Total OT =
CALCULATE (
SUMX (
MsrTable,
IF (
[HoursPerWeek] > 40,
[HoursPerWeek] - 40,
BLANK()
)
)
)

But this gives me blank.

 

What is the correct formula?
Help will be much appreciated!

4 ACCEPTED SOLUTIONS

Thank you!  I have posted the file here. 

View solution in original post

MarkS
Resolver IV
Resolver IV

Hi @barbforsman,

Could you try the OT formula as:

 

OT = if([HoursPerWeek]>40,[HoursPerWeek] - 40*[EmployeeCount],BLANK())

 
and see if that works in your scenario.

View solution in original post

Thank you!!  That works great!!

View solution in original post

hi @barbforsman,

This measure also seems to work

OTHours =
CALCULATE (
    SUMX (
        SUMMARIZE (
            R550618NLK,
            [WeekEnding],
            [Name],
            "Overtime", MAX ( [HoursPerWeek] - 40, 0 )
        ),
        [Overtime]
    ),
    ALL ( R550618NLK[Pay Type] )
)

however I would also check it, especially if an employee job title could change during the week.

View solution in original post

14 REPLIES 14
MarkS
Resolver IV
Resolver IV

Hi @barbforsman

 

Possibly try this Calculated Column:

OT Hours =
DIVIDE (
    MAX (
        CALCULATE (
            SUM ( R550618NLK[Hours] ),
            ALLEXCEPT ( R550618NLK, R550618NLK[Name], R550618NLK[WeekEnding] )
        )
            - 40,
        0
    ),
    CALCULATE (
        COUNT ( R550618NLK[Hours] ),
        ALLEXCEPT ( R550618NLK, R550618NLK[Name], R550618NLK[WeekEnding] )
    )
)

and see if this will work for you.

Thank you - but I get 3.53 for every data point?Capture2.JPG

 

Hi @barbforsman,

I think that you were using the Calculated column formula as a measure to get that result.  That formula should be entered as a calculated column on the R55.. table.

Ah - yes!  Thank you.  Thank you for the other formula as well - they both work great. 

hi @barbforsman,

This measure also seems to work

OTHours =
CALCULATE (
    SUMX (
        SUMMARIZE (
            R550618NLK,
            [WeekEnding],
            [Name],
            "Overtime", MAX ( [HoursPerWeek] - 40, 0 )
        ),
        [Overtime]
    ),
    ALL ( R550618NLK[Pay Type] )
)

however I would also check it, especially if an employee job title could change during the week.

MarkS
Resolver IV
Resolver IV

Hi @barbforsman,

Could you try the OT formula as:

 

OT = if([HoursPerWeek]>40,[HoursPerWeek] - 40*[EmployeeCount],BLANK())

 
and see if that works in your scenario.

Actually, this works for subtotals by title, but the grandtotal in the matrix is still not correct.  

Total Hours in the matrix are 8959.30 and OT total in the matrix is 8519.30, when OT should total 1119.30

I've updated the pbix file here.

 

Help will be greatly appreciated!!

Hi,

 

Why should the answer be 1119.30?  It should be 6,879.30.  See the second table in the image below.  For you to check, i have collpased the column labels at the monthly level.  The summation of individual OT hours for each month add up correctly in last column.  Here's the file.

 

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

If I look at the first line in the 2nd table, there are only 3 field engineers.  Their OT actually totals 43.25 for January, not 454.75.

There is only 1 field tech.  His OT for January totals 8.5, not 149.25.   This is an excel table with expected hours, hours worked and OT hours for all employees. 

Capture.JPG

Thank you!!  That works great!!

parry2k
Super User
Super User

if you can provide some sample data, will do the measure, just provide minimum data and mask any sensitive data.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Forgive my lack of knowledge, but I can’t see any options for attaching files. How do I do that?

it doesn't allow to attach data, you have to use google drive or dropbox or something like that to share the file.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thank you!  I have posted the file here. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.