Home > OS >  Excel formula not working while trying to calculate overtime or lesser time
Excel formula not working while trying to calculate overtime or lesser time

Time:11-08

I need to create a formula which will return overtime/lesser-time of employees based upon time duration.

I want to put the formula in column Q.

enter image description here

The requirement is such that -

  • If Total Duration(column O) is 0, then OT Hours = 0.
  • If Total Duration is >12 and Employment Type = Contractor, OT Hours = 12-O6 else O6-12.
  • If Total Duration is >8 and Employment Type <> Contractor, OT Hours = 8-O6 else O6-8.

I have entered the following formula but it is not working.

=IF(O6<>0,((IF(AND(D6<>"Contractor",O6>8),O6-8,8-O6),IF(AND(D6="Contractor",O6>12),O6-12,12-`O6))),0)`

CodePudding user response:

This should work for you:

=IF(O6=0,0,IF(D6="Contractor",IF(O6>12,O6-12,12-O6),IF(O6>8,O6-8,8-O6)))
  • Related