+ Reply to Thread
Results 1 to 12 of 12

Simplifying the calculation in a complex formula to only sum hours where day is Saturday

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

    Exclamation Simplifying the calculation in a complex formula to only sum hours where day is Saturday

    =SUMIFS(MG3:MT3,MG$2:MT$2,">1",MG$2:MT$2,"<7",MG3:MT3,">8",MG3:MT3,"<=10")-(COUNTIFS(MG$2:MT$2,">1",MG$2:MT$2,"<7",MG3:MT3,">8",MG3:MT3,"<=10")*8)+COUNTIFS(MG$2:MT$2,">1",MG$2:MT$2,"<7",MG3:MT3,">10")*2+SUMIFS(MG3:MT3,MG$2:MT$2,7,MG3:MT3,"<=8")+(COUNTIFS(MG$2:MT$2,7,MG3:MT3,">8")*8)

    Where row 1 is the date and row 2 is the day I am looking for MV3 (time and half column) to only look where the day is Saturday and sum what are the hours entered for those days.

    The formula above summed the first 8 hours because >8 goes into double time. Now the business rules have changed (meh) and all hours regardless of amount and where the day worked is Saturday = time and a half.

    So if there was only two saturdays on a paycycle and the operator worked 8 and 12 hours MV would show 20

    Can you help?

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    So you only want the sum of hours worked on Saturday?

    Let's assume:

    B1:J1 are dates
    B2:J2 are the hours worked

    Sum of Saturday hours is:

    =SUMPRODUCT(--(WEEKDAY(B1:J1)=7),B2:J2)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

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

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    Bingo...except some backtracking by me as I forgot about a small but vital element..

    Looking at range where I enter hours of DM3:DZ3 and where a shift is a Monday to Friday and >8 =<10 hours then first 8 hours is basic then those two hours are calculated as Time and Half. Anything over 10 hours is then double

    Is there a way to incorporate your formula in so if I work on a monday for 9 hours and say 10 on a Saturday that the Time and Half column (EB3) will show 19


    =SUMPRODUCT(--(WEEKDAY(B1:J1)=7),B2:J2) +

    Existing Formula

    =SUMIFS(DM3:DZ3,DM$2:DZ$2,">1",DM$2:DZ$2,"<7",DM3:DZ3,">8",DM3:DZ3,"<=10")-(COUNTIFS(DM$2:DZ$2,">1",DM$2:DZ$2,"<7",DM3:DZ3,">8",DM3:DZ3,"<=10")*8)+COUNTIFS(DM$2:DZ$2,">1",DM$2:DZ$2,"<7",DM3:DZ3,">10")*2+SUMIFS(DM3:DZ3,DM$2:DZ$2,7,DM3:DZ3,"<=8")+(COUNTIFS(DM$2:DZ$2,7,DM3:DZ3,">8")*8)

    Double Time formula (I will replace 7 with 6 so that it does not pick up Saturday hours)

    =SUMIFS(DM3:DZ3,DM$2:DZ$2,">1",DM$2:DZ$2,"<7",DM3:DZ3,">10")-(COUNTIFS(DM$2:DZ$2,">1",DM$2:DZ$2,"<7",DM3:DZ3,">10")*10) +SUMIFS(DM3:DZ3,DM$2:DZ$2,7,DM3:DZ3,">8")-(COUNTIFS(DM$2:DZ$2,7,DM3:DZ3,">8")*8)+SUMIFS(DM3:DZ3,DM$2:DZ$2,1)

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    I don't understand what your other formulas are doing.

    I would need to see the file or a SMALL sample file that demonstrates your setup to figure out what you're trying to do.

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

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    Of course, should have included before

    Attached is a sample of the whole file

    I've added dummy hours in for the Saturday 16th March to Monday 18th March (12 hours in each)

    What I hope to have is

    Basic = 8 (this behaviour is correct)
    Time and Half O/T = 14 (12 for Saturday and 2 for Monday)
    Double = 14 (12 for Sunday and 2 for Monday)

    Hope that makes sense

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    Quote Originally Posted by Baiona View Post
    What I hope to have is

    Basic = 8 (this behaviour is correct)
    Time and Half O/T = 14 (12 for Saturday and 2 for Monday)
    Double = 14 (12 for Sunday and 2 for Monday)
    Can you explain the rules of how you arrive at those expected results?

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

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    No problem

    Using MZ3:NM3 as an example where calcs are then displayed in NN3:NP3

    See my previous post of "Calculating Overtime in one cell - is it possible"

    Rules are for ->
    Monday to Friday:
    - first 8 are 'Basic' (NN3)
    - 9 and 10 are time and half (NO3)
    - >10 is double time (NP3)

    Saturday - all hours are (this is where the business rule has changed) in time and half (NO4)

    Sunday - all hours are in double time

    The cells where the calcs are

    NN3 - takes all the weekdays and sums all hours that are =<8
    NO3 - takes all Saturday hours and all weekday hours >8 but <=10
    NP3 - takes all Sunday hours and all weekday hours >10

    Note that the code also needs to cater for text being entered in the cells (such as RDO, Hols, Sick etc)

    NN3 - works fine
    NO3 - needs to be fixed to sum all Saturday hours as at moment only takes first 8 (balance then goes to double time)
    NP3 - I can fix this to now ignore Saturday by simply updating the day range it looks at, I believe

    Hope it makes sense and can help

    B

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    Sorry, I've been away for a few days.

    Is this still unresolved?

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

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    still unresolved...No one loves me!

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

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    Hi there

    Can anyone help me, please. Would love to fix this so that Saturday sums all hours and not just upto 8.

    in summary:

    I have attached a sample spreadsheet and using MZ3:NM3 as an example this is the existing behaviour of the formulas in NN3:NP3

    NN3 - Basic Hours: Sums all hours from Monday to Friday that are upto 8hrs daily. Eg: Monday to Friday 8 * 5 = 40. This cell ignores any hours that go over the maximum 8 as the balance is summed in NO3 or NP3 depending on total
    NO3 - Time and Half: All Monday to Friday hours that are >8 but <10 and all Saturday hours that are <=8. Eg: Monday I work 9 hours and 6 hours on Saturday then NO3 = 7
    NP3 - Double Time: All Sunday hours and any hours Monday to Friday >10 and Any Saturday >8

    I would like to simplify this so that cell NO3 sums all hours that are logged on saturday and includes Monday to Friday hours where a shift has 2 time and haf hours

    Otherwise all good!
    Basic hours - this is fine
    Double Time - I can change the formula to ignore Saturday (day 7)

  11. #11
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,698

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    Hello Baiona,

    This part at the end of the NO3 formula calculates the Saturday hours currently

    SUMIFS(MZ3:NM3,MZ$2:NM$2,7,MZ3:NM3,"<=8")+(COUNTIFS(MZ$2:NM$2,7,MZ3:NM3,">8")*8)

    The SUMIFS part gives you Sat all hours <=8 and the COUNTIFS part gives you 8 hours for each instance >8, so if you want to simply sum all Sat hours change that to a basic SUMIF

    =SUMIF(MZ$2:NM$2,7,MZ3:NM3)

    so combined with the first part for MF hours the NO3 formula can be this:

    =SUMIFS(MZ3:NM3,MZ$2:NM$2,">1",MZ$2:NM$2,"<7",MZ3:NM3,">8",MZ3:NM3,"<=10")-(COUNTIFS(MZ$2:NM$2,">1",MZ$2:NM$2,"<7",MZ3:NM3,">8",MZ3:NM3,"<=10")*8)+COUNTIFS(MZ$2:NM$2,">1",MZ$2:NM$2,"<7",MZ3:NM3,">10")*2+SUMIF(MZ$2:NM$2,7,MZ3:NM3)

    If you can only have whole numbers of hours that are in the 8 to 10 category (Monday to Friday), e.g. 9 or 10 then you could simplify that to this version

    =COUNTIFS(MZ$2:NM$2,">1",MZ$2:NM$2,"<7",MZ3:NM3,9)+COUNTIFS(MZ$2:NM$2,">1",MZ$2:NM$2,"<7",MZ3:NM3,">=10")*2+SUMIF(MZ$2:NM$2,7,MZ3:NM3)
    Audere est facere

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

    Re: Simplifying the calculation in a complex formula to only sum hours where day is Saturd

    Sorry for the late reply

    But basically super - works great thanks! And thank you for the explanation as it helps to see how and where it all works

    Otherwise for the double time I've removed this statement from the double time column as this ignores Saturday, right

    +SUMIFS(NS3:OF3,NS$2:OF$2,7,NS3:OF3,">8")-(COUNTIFS(NS$2:OF$2,7,NS3:OF3,">8")*8)


    Old Double time

    =SUMIFS(NS3:OF3,NS$2:OF$2,">1",NS$2:OF$2,"<7",NS3:OF3,">10")-(COUNTIFS(NS$2:OF$2,">1",NS$2:OF$2,"<7",NS3:OF3,">10")*10) +SUMIFS(NS3:OF3,NS$2:OF$2,7,NS3:OF3,">8")-(COUNTIFS(NS$2:OF$2,7,NS3:OF3,">8")*8)+SUMIFS(NS3:OF3,NS$2:OF$2,1)

    New Sunday/Double time

    =SUMIFS(NS3:OF3,NS$2:OF$2,">1",NS$2:OF$2,"<7",NS3:OF3,">10")-(COUNTIFS(NS$2:OF$2,">1",NS$2:OF$2,"<7",NS3:OF3,">10")*10) +SUMIFS(NS3:OF3,NS$2:OF$2,1)

    thanks again

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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