Calculate overtime per day based on multiple rows

Hi all

I'm trying to calculate the total overtime an employee has. Everything above 8 hours per day is overtime. My problem is, that an employee can have more than one entry (row) per day.

Example: 

employeeIDdateduration
101.05.202204:00:00
101.05.202203:00:00
101.05.202202:30:00
102.05.202206:00:00
102.05.202201:00:00

I need a formula that calculates the "01.05.2022" as "01:30:00" overtime and the "02.05.2022" as "-01:00:00" overtime. It should result in giving me back an overall overtime value as "00:30:00".

Is this possible to do with an app formula or google sheet formula?

Thanks in advance.
Adrian

Solved Solved
0 4 199
1 ACCEPTED SOLUTION

Hello @eddie61, you're getting that error when using @TeeSee1's solution because he assumed that you would have a DATE column in the table where you perform the calculation, which is expected, otherwise you wouldn't be able to make this calculation for different dates.

In case you actually don't need that, here is the expression without the date condition:

SUM(
 SELECT(your table[duration],[empId]=[_THISROW].[empId])
)
-
"008:00:00"

 

View solution in original post

4 REPLIES 4

You can try

SUM(
 SELECT(your table[duration],AND([empId]=[_THISROW].[empId],[date]=[_THISROW].[date]))
)
-
"008:00:00"

Thank you @TeeSee1 for looking into my problem.

I get an error that it cannot find the column 'date' in [_THISROW].[date].

Maybe I need to clarify what I need.

Table with data (log table)

employeeIDdateduration
101.05.202204:00:00
101.05.202203:00:00
101.05.202202:30:00
102.05.202206:00:00
102.05.202201:00:00
201.05.202204:00:00
201.05.202205:00:00

Table with the calculation (employee table)

employeeIDovertime (here I need the calculation / formula)
100:30:00
201:00:00

Does that make sense?

Edit: I also just realised that I probably need a Google Sheet Formula, because the rows in the employee table rarely get updated within the app, so the app formulas aren't computed.

Hello @eddie61, you're getting that error when using @TeeSee1's solution because he assumed that you would have a DATE column in the table where you perform the calculation, which is expected, otherwise you wouldn't be able to make this calculation for different dates.

In case you actually don't need that, here is the expression without the date condition:

SUM(
 SELECT(your table[duration],[empId]=[_THISROW].[empId])
)
-
"008:00:00"

 

How to multiply duration by local currency value?

Top Labels in this Space