# Need to compare multiple values with =if statement, and it's invalid. [closed]

Hello there,

What I'm doing is creating a spreadsheet to track my overtime. I get overtime in two ways 1) If I work over 40 hours in a week or 2) if I work over 8 hours in one day (regardless of the total amount of hours worked in the week).

I have my values set in columns B through H (where H is Sunday). What I'm putting in as my =if statement is this

```
=if(I9>40,I9-40+H9,((=if((B9-8)>0,B9-8,0))+(=if((C9-8)>0,C9-8,0))+(=if((D9-8)>0,D9-8,0))+(=if((E9-8)>0,E9-8,0))+(=if((F9-8)>0,F9-8,0))+H9))
```

and I'm getting Invalid Expression. I'm not sure what's wrong exactly, unless it's that I can't have multiple =if statements in the last part. If that's the case, is there an easy way of doing this? My original statement is this:

```
=if(I9>40,I9-40+H9,(B9-8+C9-8+D9-8+E9-8+F9-8+H9))
```

which places a negative value in the overtime column (it should be 0 unless I have overtime), and it slowly moves towards the correct value (either 0 or the overtime amount) as I add hours.

Thanks for any help with this, and have a great day:) Patrick.

P.S. An example of what I'm looking for is this:

```
A9=8 B9=10 C9=8 D9=8 E9=0 F9=0 G9=0 H9=0 and the overtime should read 2
A9=8 B9=8 C9=8 D9=8 E9=8 F9=8 G9=0 H9=0 and the overtime should read 0
A9=8 B9=8 C9=8 D9=8 E9=8 F9=8 G9=8 H9=0 and the overtime should read 8
A9=8 B9=8 C9=8 D9=8 E9=8 F9=8 G9=0 H9=8 and the overtime should read 16 (double time on Sunday)
```