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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
acg
Resolver I
Resolver I

Which person has worked Overtime and how many times within a certain timeframe?

Hi, 

 

I like to solve the following problem:

 

In a company some employees have worked more than 10% overtime. The task is to monitor who is consistently working overtime over the past 6 weeks and how often. 

 

Below is some example data. 

 

There is a time variable: last day of week, the Employee ID, the overtime done in PCT, and I worked out an OvertimeCount:

OTCount = IF([Overtime Pct]>=10,1,0) to indicate employees that have worked over 10% -  ideally that would be a slicer that allows me to chaoose the Percentage (10% or 20%), but I think I would need to do different counts for that, one for 10% and one for 20%.
 
More pressing though, How can I create a slicer that shows me all employes that have worked 2,3,4 etc times over time (based on 10% overtime or 20% etc) 
 
I think the OTTotal should help, yet I cannot put this measure into a slicer:
OTTotal =
VAR _Total = SUMX(VALUES('Timesheet Data'[Employee ID]),[OTCount])
RETURN IF(HASONEVALUE('Timesheet Data'[Employee ID]),[OTCount],_Total)

 

 

How can I showcase how many and which employee has worked overtime more than twice within a certain timeframe?

 

last_day_of_weekEmployee IDOvertime PctOTCountOTTotal
20/06/2021122.800
27/06/20211232.611
4/07/2021127.600
11/07/20211226.411
18/07/20211220.811
25/07/20211228.511
11/07/202122 00
18/07/202122 00
25/07/2021220.000
1/08/202122 00
20/06/2021475.800
27/06/2021471.300
4/07/202147 00
11/07/2021471.300
18/07/202147 00
25/07/202147 00
27/06/202155 00
4/07/2021555.000
11/07/202155 00
18/07/202155 00
25/07/202155 00
20/06/2021611.311
27/06/20216 00
4/07/2021612.511
11/07/20216 00
18/07/20216 00
25/07/2021611.311
20/06/2021350.600
27/06/2021350.600
4/07/2021351.900
11/07/20213523.811
18/07/2021352.500
25/07/20213511.911
20/06/2021428.800
27/06/2021428.800
4/07/2021426.900
11/07/2021425.000
18/07/2021425.000
25/07/20214216.311
1/08/2021426.300
20/06/202111 00
27/06/20211125.011
4/07/202111 00
11/07/20211125.011
18/07/2021116.300
25/07/20211125.011
1/08/202111 00
20/06/202127 00
27/06/202127 00
4/07/202127 00
11/07/202127 00
18/07/202127 00
25/07/202127 00
1 ACCEPTED SOLUTION
ERD
Community Champion
Community Champion

Hi @acg ,

Assuming there are measures (took from your previous post):

OT = 
VAR currentEmpID = MAX ( T[Employee ID] )
VAR currentLDW = MAX ( T[last_day_of_week] )
VAR currentContractHours = MAX ( T[Contract_Hours] )
VAR OT =
    CALCULATE (
        SUM ( T[Hours] ),
        FILTER (
            ALL ( T[Employee ID], T[last_day_of_week] ),
            T[Employee ID] = currentEmpID
                && T[last_day_of_week] = currentLDW
        )
    ) - currentContractHours
RETURN
    IF ( OT > 0, OT )
OT% = 
VAR currentContractHours = MAX ( T[Contract_Hours] )
VAR OT = [OT] / currentContractHours
RETURN
    OT
OT>10% = IF([OT%] >= 0.1, 1, 0)

Your OTTotal measure can be created this way:

OTTotal = 
VAR _t =
    ADDCOLUMNS (
        SUMMARIZE ( T, T[last_day_of_week], T[Employee ID] ),
        "@v", [OT>10%]
    )
RETURN
    SUMX ( _t, [@v] )

 

ERD_0-1627465891845.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

View solution in original post

3 REPLIES 3
ERD
Community Champion
Community Champion

Hi @acg ,

Assuming there are measures (took from your previous post):

OT = 
VAR currentEmpID = MAX ( T[Employee ID] )
VAR currentLDW = MAX ( T[last_day_of_week] )
VAR currentContractHours = MAX ( T[Contract_Hours] )
VAR OT =
    CALCULATE (
        SUM ( T[Hours] ),
        FILTER (
            ALL ( T[Employee ID], T[last_day_of_week] ),
            T[Employee ID] = currentEmpID
                && T[last_day_of_week] = currentLDW
        )
    ) - currentContractHours
RETURN
    IF ( OT > 0, OT )
OT% = 
VAR currentContractHours = MAX ( T[Contract_Hours] )
VAR OT = [OT] / currentContractHours
RETURN
    OT
OT>10% = IF([OT%] >= 0.1, 1, 0)

Your OTTotal measure can be created this way:

OTTotal = 
VAR _t =
    ADDCOLUMNS (
        SUMMARIZE ( T, T[last_day_of_week], T[Employee ID] ),
        "@v", [OT>10%]
    )
RETURN
    SUMX ( _t, [@v] )

 

ERD_0-1627465891845.png

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

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Hi ERD, strangely enough this does not work. THe measure translates fine, but I can not display it in a table. I also tried to use it in a slicer. 

You are right, it is a follow up question from the previous post and OT, OT Perc and OT>10% are all measures.  So the build up of the variables should not be the problem. 

Any ideas why that would be?  Does the 

"@v"

not need to be introduced?

From what I know , I should be able to place any of the variables below into a slicer to filter on it. Would that be right, as the filter needs to be able to direct the week of choice, the ID as well as how often ID x has worked over time. 

Thank you for your help. 

 

   SUMMARIZE ( T, T[last_day_of_week], T[Employee ID] ),

 

acg
Resolver I
Resolver I

Should result in something like this:

Employee IDOTTotal
124
220
470
550
63
352
421
113
110
270

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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