+ Reply to Thread
Results 1 to 24 of 24

Calculating Overtime hours in one cell - is it possible

  1. #1
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Calculating Overtime hours in one cell - is it possible

    Hi there

    I'm new to the forum and hope the brain's trust can put me right. Needs must! I've tried Countifs, sumifs, productifs...I basically don't have the right syntax...

    I am trying to have excel calculate overtime hours as numbers are inputted in other cells

    It's easy enough where we have technicians working on a weekend - value is multiplied by 1.5 and shown in AK

    eg: =SUM(V3,AB3:AC3,AI3)*1.5

    However....

    What I would also like to do in column AK then every 18 columns in the range is have a calculation take place that looks at the weekday hrs. Where the value is over 8 but under 10 then column AK will add the overtime amount of 0.5 and where the value is greater than 10 will do double time

    In other words

    Where Mon to Fri is > 8 =< 10 then 2 hrs should be mulitplied by 0.50
    eg: 9 hours = 9.5hrs so AK increments 0.5
    Where Mon to Fri is >10 then hours first two hours over 8 are multiplied by 0.5 and then multiplied by 2
    eg: 12 hours = 15hrs so AK increments by 3

    How on earth do I do this and also ensure my existing calculation for weekends is not affected.

    Hoping it's possible or other suggestions would be most appreciated

    B
    Attached Files Attached Files
    Last edited by FDibbins; 01-22-2013 at 01:58 AM.

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculating Overtime hours in one cell - is it possible

    Hi and welcome to the forum

    I think I have what you want.

    1st, instead or using text for the weekdays (row 2) use this, copied across...
    =WEEKDAY(V1,1)
    format custom as ddd this will give you a weekday for each day

    next, you have 2 options.
    OPTION 1
    this will split the OT calc into 3 parts - weekday OT <10, W/D OT > 10, W/E OT
    add 3 helper columns before your current OT column (AK)
    in the 1st column, calc OT <10, use this, copied down
    =(SUMIFS(V3:AI3,V1:AI1,">1",V1:AI1,"<7",V3:AI3,">8",V3:AI3,"<10")-(COUNTIFS(V1:AI1,">1",V1:AI1,"<7",V3:AI3,">8",V3:AI3,"<10")*8))+(SUMIFS(V3:AI3,V1:AI1,"<6",V3:AI3,">=10")-(COUNTIFS(V1:AI1,"<6",V3:AI3,">=10")*10))*1.5
    in the 2nd column, calc OT >10, use this, copied down
    =(SUMIFS(V3:AI3,V1:AI1,"<6",V3:AI3,">=10")-(COUNTIFS(V1:AI1,"<6",V3:AI3,">=10")*10))*2
    in the 2rd column, calc WE OT, use this, copied down
    =(SUMIFS(V3:AI3,V$2:AI$2,1)+SUMIFS(V3:AI3,V$2:AI$2,7))*1.5
    in your current OT column (now AN), add them together
    =SUM(AK3:AM3)

    OPTION 2
    dont use helper columns and have all of the above combined into 1 cell (which is what you want, I think, but it will be much harder to edit or modify later)
    =(SUMIFS(V3:AI3,V1:AI1,">1",V1:AI1,"<7",V3:AI3,">8",V3:AI3,"<10")-(COUNTIFS(V1:AI1,">1",V1:AI1,"<7",V3:AI3,">8",V3:AI3,"<10")*8))+(SUMIFS(V3:AI3,V1:AI1,"<6",V3:AI3,">=10")-(COUNTIFS(V1:AI1,"<6",V3:AI3,">=10")*10))*1.5
    +(SUMIFS(V3:AI3,V1:AI1,"<6",V3:AI3,">=10")-(COUNTIFS(V1:AI1,"<6",V3:AI3,">=10")*10))*2
    +(SUMIFS(V3:AI3,V$2:AI$2,1)+SUMIFS(V3:AI3,V$2:AI$2,7))*1.5

    I have a feeling that later you will also want to split W/E OT >10, OPTION 1 will make doing this adjustment easier
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,581

    Re: Calculating Overtime hours in one cell - is it possible

    The following array formula to be used in R14 cell and then copied to other cells.

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Hey FDibbins

    Wow, magnificent!

    So I went with Option 1 (as you're kinda right - see below)...after including the three columns (A3:C3) and updating cells accordingly looking at Y2 (ddd) etc these are my updated formulae

    =(SUMIFS(Y3:AL3,Y2:AL2,">1",Y2:AL2,"<7",Y3:AL3,">8",Y3:AL3,"<10")-(COUNTIFS(Y2:AL2,">1",Y2:AL2,"<7",Y3:AL3,">8",Y3:AL3,"<10")*8))+(SUMIFS(Y3:AL3,Y2:AL2,"<6",Y3:AL3,">=10")-(COUNTIFS(Y2:AL2,"<6",Y3:AL3,">=10")*10))*1.5

    =(SUMIFS(Y3:AL3,Y2:AL2,"<6",Y3:AL3,">=10")-(COUNTIFS(Y2:AL2,"<6",Y3:AL3,">=10")*10))*2

    =(SUMIFS(Y3:AL3,Y2:AL2,"<6",Y3:AL3,">=10")-(COUNTIFS(Y2:AL2,"<6",Y3:AL3,">=10")*10))*2

    There's a mistake, though, and I think it's my fault as the calculations are slightly out. I've reattached my workings but it seems column b is miscalculating Weekdays in different ways (eg: 9 hours on a Thursday calculates 10hrs instead of 9.5hrs, Friday (AD) is ignored).

    Can you do some more magic? And to brief creep can I move the goal posts....where it's a Sunday it's double time. So 5 hrs = 10hrs etc. I tried to play and update it myself (hence why the delay in responding) but failed miserably

    Many thanks

    B
    Attached Files Attached Files

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculating Overtime hours in one cell - is it possible

    I used a single array formula (no helper cells) to get the total overtime, i.e. this formula for AN3

    =SUM(IF(Y$2:AL$2=1,Y3:AL3*2,IF(Y$2:AL$2=7,Y3:AL3*1.5,CHOOSE(MATCH(Y3:AL3,{0,9,10}),0,0.5,Y3:AL3-9))))

    confirmed with CTRL+SHIFT+ENTER

    That calculates Sundays @ time *2, Saturdays @ time * 1.5 and weekdays as per your description - that gives me 54.5 for your example
    Audere est facere

  6. #6
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Hey

    Definitely an elegant formula. You guys rock! Can you confirm this takes into account the >8<10hrs @ time and half and >10 @ double time for weekdays? I calculate the Weekend hours and Weekday OT at 55hrs and not 54.5. Can you advise where the rounding up, if that is the problem, occurs

    If I take Sundays as being double time and Saturdays as time and a half I calculate there should only be in total 138 hrs which is 83 normal hours + 55 as OT. Reattached file for anyone interested but looking purely at the new formula

    If I can account for that 30 minutes (is it me or is it you??) then I can finally put this to bed!!
    Last edited by Baiona; 01-18-2013 at 07:42 AM. Reason: updated spreadhseet

  7. #7
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Ahem...I'm now thinking i've made this more complicated than I needed to...

    I'm going to go back in and see if I can figure out with the workings already provided how to make three columns

    Normal Hours: =< 8 Weekdays
    Time n Half: >8<10 Weekdays and Saturday hrs =<8
    Double Time: >10rs and Sunday hrs

    I can do this...but er, look out for my enquiry later

    B

  8. #8
    Forum Expert Kevin UK's Avatar
    Join Date
    12-07-2010
    Location
    Radstock, Somerset
    MS-Off Ver
    365
    Posts
    1,922

    Re: Calculating Overtime hours in one cell - is it possible

    Hi Baiona

    Good idea. Best to keep things simple just in case someone else has to work on it.
    Regards Kevin


    Merged Cells (They are the work of the devil!!!)

  9. #9
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: indicating Overtime where appropriate

    Hello again

    Well I give up trying to do this myself so I have spent the time simplifying what I'm trying to achieve and going back over my maths, which was woeful (apologies), I realise I don't need the calculation then multiplication of hrs where appropriate. I simply need to have them identified

    I have reattached my spreadsheet and inserted comments and some basic calculations, which this time are correct! (Should be template D)

    What I'm looking to now do is look at a 14 day range (eg: AA3:AN3,AA2:AN2), which I can then copy over the range of the spreadsheet and:

    Where Mon to Fri =<8 then amount in "Hrs"
    Where Mon to Fri is > 8 < 10 then 8 in "Hrs" and upto 2 hrs in "*1.5" cell
    Where Mon to Fri >10 hrs then 8 in "Hrs", 2 in "*1.5" then rest in "*2"
    Where Saturday hours first 8 hours in "*1.5" then balance in "*2"
    Where Sunday all hours in "*2"

    I don't then need the sums multiplied. I can do that myself if I wish/need/require

    I'm happy to go with helper columns or whichever is easiest. One thing, though, is that the cells might also have Sick or Hols in them to indicate etc. Therefore any formula needs to manage there being potential text in the range

    Please, please can you help?
    Attached Files Attached Files

  10. #10
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Calculating Overtime hours in one cell - is it possible

    OK, going with that simpler approach try these formulas:

    In AB23 copied across for normal hours

    =IF(OR(AB21={"Sat","Sun"}),0,MIN(8,N(AB22)))

    then in AB25 copied across for double time hours

    =MAX(0,N(AB22)-IF(AB21="Sun",0,IF(AB21="Sat",8,10)))

    and finally in AB24 the formula can give you all the remaining hours at "time and a half"

    =N(AB22)-AB23-AB25

    Using N(AB22) will return the number from AB22 if it contains a number........but zero if it contains text - so the formulas cope with text like "sick" or "hols"

  11. #11
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Dang. Sorry for the confusion...

    I was just showing my manual workings to ensure my maths was right. I'm hoping to have those calculations show in AO:AQ cells. So basically the hours still entered say from AA3:AN9 and results presented in the cells where the comments are

  12. #12
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Identifying Overtime - Time and Half and Double Time hours

    Bump - no response

    Really hoping you might be able to get me across the line, chaps

    To summarise I've reattached my spreadsheet with comments in the hope you might be able to help with what I have to enter in cells AO:AQ

    Thanks in advance!
    Attached Files Attached Files

  13. #13
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculating Overtime hours in one cell - is it possible

    OK, these get pretty big, so test them well...
    in AO use this...
    Please Login or Register  to view this content.
    in AP use this....
    Please Login or Register  to view this content.
    and in AQ use this...
    Please Login or Register  to view this content.
    let me know how you make out please?

  14. #14
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Thank the lord! Works brilliantly, thanks. I am resolving this with pleasure. Thanks for your time, you've been a lot of help

  15. #15
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculating Overtime hours in one cell - is it possible

    Happy to help and glad we arrived at what you wanted

    Thanks for the rep, too

  16. #16
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Hey FD

    I missed this in testing the calcs and sods law I find out with real hours. Problem is with Saturday (only) and when hours are >10

    The formulae actually minuses the hours in the time and half - from 1 to 10 all is good and behaviours are correct. But if I enter 11 hours I have the time and half column showing -3 and nothing in double time. I've entered dummy figure in AC:AD

    Can you have a peek and advise, please

    B

  17. #17
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculating Overtime hours in one cell - is it possible

    Hi again

    Sorry, I gotta get my head into this again lol Just tto confirm, we are still using these rules, right?

    Where Mon to Fri is > 8 < 10 then 8 normal hours and up to 2 hrs in "*1.5" cell
    Where Mon to Fri >10 hrs then 8 normal hours, 2 in "*1.5" then rest in "*2"
    Where Saturday hours first 8 hours in "*1.5" then balance in "*2"
    Where Sunday all hours in "*2"

    in other words
    W/D to 8 = regular time
    W/D to 10 = 2hr @ 1.5
    W/D to 12 = 2hr @ 1.5 + 2hr @ 2
    Sat to 8 = 1.5
    Sat past 8 = @ 2
    all Sun = @ 2

    so Sat 11 hrs =
    8 hrs @ 1.5
    3 hrs @ 2

  18. #18
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Hey

    That's the one. Now I see how you break it down wished I'd thought of doing it that way; would have saved some explaining...

    B

  19. #19
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculating Overtime hours in one cell - is it possible

    Ok thanks, just wanted to make sure.

    I will work on it and get back to you (its getting a bit late here now, so I will probably take a look inthe morning when im fresh)

    edit: test these, they seem to work according to your rules now.
    for the 1.5 column...
    Please Login or Register  to view this content.
    for the 2 x column...
    Please Login or Register  to view this content.
    Last edited by FDibbins; 02-02-2013 at 02:47 AM.

  20. #20
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Close...

    The behaviour is bang on bar if I enter say 9 hours on Saturday the double time is correct (1 hour) but the 1.5 = 17 hours. Looked at the formula but stumped as to what the issue is

    Otherwise =<8 and >10 is perfect!

  21. #21
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    so if I enter 9 hours it calculates 8 + 9 = 17 and 10 hours is 8 +10 = 18

  22. #22
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculating Overtime hours in one cell - is it possible

    Ok, I think I have it this time...

    for the 1.5....
    Please Login or Register  to view this content.

  23. #23
    Registered User
    Join Date
    01-09-2013
    Location
    Sydney, Australia
    MS-Off Ver
    2018
    Posts
    27

    Re: Calculating Overtime hours in one cell - is it possible

    Thank you for your time sir, works magnificently.

    Next time I bother you it'll hopefully be with a new enquiry!

    B

  24. #24
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Calculating Overtime hours in one cell - is it possible

    Happy to help, look forward to your next question

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1