Forum Discussion
Calculate extra hours
- 6 years ago
I put your example data in and made two What If parameters - StartTime and StopTime (with values from 0 to 24 hours). If that is correct, you can use an expression like this to calculate the total overtime hours. Note this subtracts the difference between the two parameters from the time difference for the shift each day.
Total Overtime =
VAR selectedduration = StopTime[StopTime Value] - StartTime[StartTime Value]
RETURN
SUMX (
Shift,
VAR overtime = ( Shift[End Time] - Shift[Start Time] ) * 24 - selectedduration
RETURN
IF ( overtime > 0, overtime, 0 )
)If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
I put your example data in and made two What If parameters - StartTime and StopTime (with values from 0 to 24 hours). If that is correct, you can use an expression like this to calculate the total overtime hours. Note this subtracts the difference between the two parameters from the time difference for the shift each day.
Total Overtime =
VAR selectedduration = StopTime[StopTime Value] - StartTime[StartTime Value]
RETURN
SUMX (
Shift,
VAR overtime = ( Shift[End Time] - Shift[Start Time] ) * 24 - selectedduration
RETURN
IF ( overtime > 0, overtime, 0 )
)
If this works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
Thank you..
I used your method but did a little adjustement