Thread: IF formula Thanks:  7 Post #5337968 (1)Post #5347587 (1)Post #5337996 (1)Post #5336772 (1)Post #5338008 (1) Likes:  2 Post #5337968 (1)Post #5337996 (1)

1. IF formula

I am doing timesheets and the following is the layout

E F G H I J
Start Break Finish Normal Hours Time & Half Double Time
08:30 1:00 19:30 8 3 2

Under the H cell I use this formula =IF(((G5-F5-E5)*24)>8,8,(G5-F5-E5)*24) to calculate the hours and to stop them at 8

Under the I cell I have this formula =IF(((G5-F5-E5)*24)>8,((((G5-F5-E5)*24)-8)*1.5)) to calculate the remainder of the hours at time and a half (X1.5)

Under the J Cell I have this formula =IF(((G5-F5-E5)*24)>8,((((G5-F5-E5)*24)-8)*1.5)>2)*2 to calculate the remainder as double time

What I need is the I cell (time and a half) to work similar to the H cell so I need it to take the remainder of the hours worked which in this example is 2 hours multiply it by 1.5 (which works in the formula I have used) now I need it to stop at 2 and then I need the rest of the hours which would be 1 to multiply in the J cell to double time (x2)

Can anyone help please TIA Reply With Quote

2. Re: IF formula help

Do I understand you correctly?

You want all hours worked up to 8 hours to be counted as 1.
All hours worked between 8 and 10 counted x1.5. So up to two hours can be counted x1.5
All hours worked over 10 counted x2.

If so:

Column I (x1.5).
The number 2 marked red can be changed to increase/decrease the amount of hours for which x1.5 applies.
=IF(((G5-F5-E5)*24)>8,(MIN((((G5-F5-E5)*24)-8),2)*1.5))

Column J (x2.0).
The number 10 marked red can be changed to modify the hour at which x2.0 starts.
=IF(((G5-F5-E5)*24)>10,((G5-F5-E5)*24)-10)*2 Reply With Quote

3. Re: IF formula help

Hi Nunya1,

I've just answered an identical question for Shazzi1005 but without the break hour(s).
https://www.mrexcel.com/forum/excel-...ml#post5336244

The same answer applies but with the break subtracted, as you've identified. I've added a total hours worked column for clarity.

E F G H I J K L
3 Start Time Break End Time Cap at 8 8 to 10 x 1.5 Over10 x 2 Hours Worked
4 9:00 1:00 18:00 8 0 0 8
5 8:30 1:00 19:30 8 3 0 10
6 7:00 1:00 21:00 8 3 6 13
7 10:00 2:00 16:00 4 0 0 4
Nunya1

Worksheet Formulas
Cell Formula
H4 =IF(((G4-F4-E4)*24)>8,8,(G4-F4-E4)*24)
I4 =IF(((G4-F4-E4)*24) > 8,MIN(((G4-F4-E4)*24),10)-8)*1.5
J4 =IF(((G4-F4-E4)*24) > 10,((((G4-F4-E4)*24)-10)*2),0)
L4 =((G4-F4-E4)*24) Reply With Quote

4. Re: IF formula help

Ta I just flicked over to the other post and it answered my question. Reply With Quote

5. Re: IF formula help

One more thing - So below is what our timesheets look like. Now the guys can do more then 1 job a day so if for the first job (row 4) they work the 8 hours then the second line (Row 5) they worked 4 hours then that row should go into the overtime hours so how can I get it to recognise that if rows 4-6 total 8 all together under normal then the first 1.33 hours is time and a half and the rest of the hours go in at double time. Each one is rows 4-6 and also why is my formula showing false until I enter data in times?

I am using the formulas written in this thread except in time and half I am using this formula =IF(((G4-F4-E4)*24)>8,(MIN((((G4-F4-E4)*24)-8),1.333333)*1.5))

 Day Site Name Job No Date Start Time Break Finish Time Normal 1.5 Time 2.0 Time On Call TOIL Taken Public Holiday Sick Leave Annual Leave \$70.00 \$130.00 \$195.00 Monday 1-Jan-19 07:00am 09:00pm 8.00 2.00 8.00 09:00am 12:00pm 3.00 FALSE 0.00 12:00pm 01:00 04:00pm 3.00 FALSE 0.00 Tuesday Wednesday Thursday Reply With Quote

6. Re: IF formula help

Hi Nunya1,

So this needs a different approach and a change to the structure of the sheet.

The Normal, OT1 and OT2 hours can only be calculated after the last entry for that day, so I need the date repeated for each row with times and I need a new column "Hours" so I can total up the hours for a day and then calculate.

Cell formulae H2, I2, J2 and K2 should be copied down as far as the last row which may have times entered.

The formulae search the whole column (i.e. H:H and D:D) but if you've other data in lower rows then you should limit the range to those which have times entered (e.g. \$H\$2:\$H\$100 and \$D\$2:\$D\$100).

I am showing the hours for OT1 and OT2. If you want me to actually calculate those hours as multiplied by 1.5 and 2 then let me know.

A B C D E F G H I J K
1 Day Site Name Job No Date Start Time Break Finish Time Hours Normal OT 1 OT 2
2 Monday 01-Jan-19 7:00 21:00 14.00
3 01-Jan-19 9:00 12:00 3.00
4 01-Jan-19 12:00 1:00 16:00 3.00 8.00 1.33 10.67
5 Tuesday 02-Jan-19 8:30 1:00 17:00 7.50
6 02-Jan-19 7:30 1:00 16:30 8.00 8.00 1.33 6.17
7
8 Wednesday 03-Jan-19 8:00 1:00 16:30 7.50 7.50
9
10 Thurday 04-Jan-19 9:00 1:00 17:00 7.00 7.00
Nunya1 (2)

Worksheet Formulas
Cell Formula
H2 =IF(E2<>"",(G2-E2-F2)*24,"")
I2 =IF(AND(D2<>D3,D2<>""),MIN(SUMIFS(H:H,D:D,D2),8),"")
J2 =IF(AND(ISNUMBER(I2),SUMIFS(H:H,D:D,D2)>8),MIN(SUMIFS(H:H,D:D,D2)-8,1.33333),"")
K2 =IF(ISNUMBER(J2),SUMIFS(H:H,D:D,D2)-9.333333,"") Reply With Quote

7. Re: IF formula help

And how do I get the J2 to multiply by 1.5 to get a total value of 2 and the same with K2 I need it to multiply by 2 to get a total?

The formulas you gave me work appreciated that but when I try to *1.5 or *2 it just brings it up as (Value) Reply With Quote

8. Re: IF formula help

Here you go...

A B C D E F G H I J K
1 Day Site Name Job No Date Start Time Break Finish Time Hours Normal OT 1 OT 2
2 Monday 01-Jan-19 7:00 21:00 14.00
3 01-Jan-19 9:00 12:00 3.00
4 01-Jan-19 12:00 1:00 16:00 3.00 8.00 2.00 21.33
5 Tuesday 02-Jan-19 8:30 1:00 17:00 7.50
6 02-Jan-19 7:30 1:00 16:30 8.00 8.00 2.00 12.33
7
8 Wednesday 03-Jan-19 8:00 1:00 16:30 7.50 7.50
9
10 Thurday 04-Jan-19 9:00 1:00 17:00 7.00 7.00
Nunya1 (3)

Worksheet Formulas
Cell Formula
H2 =IF(E2<>"",(G2-E2-F2)*24,"")
I2 =IF(AND(D2<>D3,D2<>""),MIN(SUMIFS(H:H,D:D,D2),8),"")
J2 =IF(AND(ISNUMBER(I2),SUMIFS(H:H,D:D,D2)>8),MIN(SUMIFS(H:H,D:D,D2)-8,1.33333)*1.5,"")
K2 =IF(ISNUMBER(J2),(SUMIFS(H:H,D:D,D2)-9.333333)*2,"") Reply With Quote

9. Re: IF formula help

K still wont calculate at double time with that formula the J one works but K won'?

Appreciate your help BTW Reply With Quote

10. Re: IF formula help

It's working for me (as per the example).

1st January has three entries for 14,3 and 3 hours so total = 20.
Normal is 8 hours at flat rate x 1 = 8, so that leaves 12 hours to pay.
OT 1 is capped at 1.33333 hours and paid at 1.5 x so 1.5 x 1.33333 = 1.99999995 which Excel rounds to 2,so that leaves 20-8-1.33333 hours=10.66667
OT 2 is twice the remaining hours so 10.66667 x 2 = 21.33334 which Excel rounds to 21.33

2nd January had two entries 7.50 + 8 = 15.5 hours
Normal is 8 hours so leaving 7.5 hours
OT 1 takes 1.33333 of those 7.5 hours and x 2=2, so leaving 6.16667 hours
OT 2 takes the remaining hours and applies double rate so 6.16667 x 2 = 12.33334 which Excel rounds to 12.33

If those aren't the results you're seeing then please copy and paste the cells with your results? Reply With Quote

User Tag List

Tags for this Thread

cell, double, formula, hours, time Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•
{"ft_lang_label":"__label__en","ft_lang_prob":0.9037378,"math_prob":0.93406314,"size":580,"snap":"2019-43-2019-47","text_gpt3_token_len":195,"char_repetition_ratio":0.15277778,"word_repetition_ratio":0.043956045,"special_character_ratio":0.37586206,"punctuation_ratio":0.13605443,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9910457,"pos_list":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72],"im_url_duplicate_count":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-10-17T08:16:57Z\",\"WARC-Record-ID\":\"<urn:uuid:ca5b85cf-9417-484d-aaa1-e5d7a1b20961>\",\"Content-Length\":\"150130\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:8ba2d5f9-c9e6-4712-a540-790e06313fd0>\",\"WARC-Concurrent-To\":\"<urn:uuid:64e8d181-d0b1-4894-937e-68e736f1099f>\",\"WARC-IP-Address\":\"216.92.17.166\",\"WARC-Target-URI\":\"https://www.mrexcel.com/forum/excel-questions/1108874-if-formula.html?s=4d04a2a3b55e76d84328b9c9b1ece6a3\",\"WARC-Payload-Digest\":\"sha1:FPAWEK6MMLLQDB5SD26XVIEYXRC3HV3N\",\"WARC-Block-Digest\":\"sha1:ORRL72ZAT5DIYWIECX6FD2BDWR3LUE3F\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-43/CC-MAIN-2019-43_segments_1570986673250.23_warc_CC-MAIN-20191017073050-20191017100550-00268.warc.gz\"}"}