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.
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!
Solved! Go to Solution.
Hi @barbforsman,
Could you try the OT formula as:
OT = if([HoursPerWeek]>40,[HoursPerWeek] - 40*[EmployeeCount],BLANK())
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.
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?
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.
Hi @barbforsman,
Could you try the OT formula as:
OT = if([HoursPerWeek]>40,[HoursPerWeek] - 40*[EmployeeCount],BLANK())
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.
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.
Thank you!! That works great!!
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.
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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
111 | |
100 | |
80 | |
64 | |
58 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |