+ Reply to Thread
Results 1 to 6 of 6

Periodic cumulative sums of a single array, restarting every time a certain value appears

  1. #1
    Banned User!
    Join Date
    09-26-2015
    Location
    Manchester
    MS-Off Ver
    2013
    Posts
    218

    Periodic cumulative sums of a single array, restarting every time a certain value appears

    Hi All,

    With reference to the attached.

    Background

    This is an overtime form I want to introduce at my company, to automate the calculation of overtime. Currently the employees manually write down their overtime hours in pen and submit to the payroll clerk. Payroll clerk is then responsible for allocating overtime hours to a 30% bracket, 50% bracket in accordance with the allocation rules set out in local law etc. So far there have been some gross errors made by the clerk and these haven't been in the company's favour (which is probably the least objectionable error as it is in favour of the employees and hence we don't have labour inspectors all over us). But this highlights a need to automate this allocation process on Excel, using the legal framework provided by law as the means by which hours are allocated.

    Problem 1

    1. Local law stipulates the first 8 hours of work are paid at normal rate
    2. Local law stipulates that the first 45 hours of work per week are also at normal pay (it is important to note that in my country of operation, an 8 hour working day is standard on Monday - Friday, as is a five hour working day Saturday).
    3. Local law also stipulates an exception to rule 1 above, in that the ninth hour of work in each day will not attract overtime provided that the total weekly working hours (Sun - Sat) does not exceed 45 hours.

    Hence, it is important for me to be able to calculate the cumulative hours worked on a weekly (Sun - Sat) basis, so that I can apply rule 3 above i.e. exclude the ninth hour of work per day from the overtime calculation, if the weekly hours worked (Sun - Sat) do not exceed 45. This cumulative hours worked on a weekly basis are intended to be shown in column J.
    Hence, I need a formula in cells J43 : J73 that is capable of taking the hours worked in a day (see column I) and adding those into a weekly total (again, Sunday to Saturday). However, each overtime sheet is for a complete month and rows 43 - 73 represent all the days in a given month, so the formula I need in column J must be capable of restarting a new cumulative count every Sunday.
    To give an example, I have inserted a rigid formula in cells J43 : J54 to show what the totals would look like but this formula isn't fit for use as it is reliant on the days in column C staying static month to month (try changing the month in the drop down list in cell C28 and you will see the days change rows) hence I need a formula that is capable of detecting whether the day in column C is a Sunday ("Sun"); if so the summing of the weekly hours restarts, if not (and this is the element I'm struggling with) I need to command a cumulative count of weekly hours beginning from the last Sunday.

    You will see from in cells J62:J73 I have attempted the beginning of a formula which may be capable of doing this, but as I just said, I'm struggling with the latter element.

    Problem 2


    In column K, I need to insert a formula that is capable of doing the following:
    Generate a "Y" value if the value of hours worked on a given day (column I) exceeds 8 hours AND the cumulative hours worked for the week (which will be shown in column J on the nearest following Saturday) exceeds 45 hours (Y denoting "Yes, overtime needs to be paid on this ninth hour")
    Formula will also generate an "N" if value in column I exceeds 8 hours AND the cumulative total on the next following Saturday is less 45 hours (N denoting "No, overtime need not be paid on this ninth hour")
    Finally formula should generate a blank if both the value in column I is less than or equal to 8 hours AND the cumulative total on the following Saturday is less than 45 hours.
    I will use the "Y" or "N" values to allocate overtime hours in column L onwards.

    I have inserted an example in cell K43 (yellow cell) but again, this is formula is rigid and is not capable of detecting the nearest following Saturday. This formula also falls down (apparently!) because a value of 09:00 (cell I43) is not greater than the value of 8 given in the formula.

    Appreciate this may be a difficult ask so thanks for your time and attention in advance.
    Attached Files Attached Files
    Last edited by STUARTXL; 12-02-2016 at 10:16 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Periodic cumulative sums of a single array, restarting every time a certain value appe

    There is no attachment.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Banned User!
    Join Date
    09-26-2015
    Location
    Manchester
    MS-Off Ver
    2013
    Posts
    218

    Re: Periodic cumulative sums of a single array, restarting every time a certain value appe

    My apologies, now attached.

  4. #4
    Banned User!
    Join Date
    09-26-2015
    Location
    Manchester
    MS-Off Ver
    2013
    Posts
    218

    Re: Periodic cumulative sums of a single array, restarting every time a certain value appe

    Bump no response

  5. #5
    Banned User!
    Join Date
    09-26-2015
    Location
    Manchester
    MS-Off Ver
    2013
    Posts
    218

    Re: Periodic cumulative sums of a single array, restarting every time a certain value appe

    Which paticular part of the spreadsheet has the error? I've just downloaded the attachment myself and there doesn't appear to be a problem. If you could give a cell reference/range that would be useful.

  6. #6
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,202

    Re: Periodic cumulative sums of a single array, restarting every time a certain value appe

    For calculating weekly total:

    helper in column X

    X42=1

    X43 and copy down

    =IF($C43="Sun",MAX($X$42:X42)+1,MAX($X$42:X42))

    in J43 and copy down:

    =SUMIF($X$43:X43,X43,$I$43:I43)

    Weekly overtime calculation

    In K3

    =IFERROR(IF(AND($I43>8/24,INDEX($J43:$J$73,MATCH("Sat",$C43:$C$73,0))>45/24),"Y",IF(AND(I43>8/24,INDEX($J43:$J$73,MATCH("Sat",$C43:$C$73,0))<45/24),"N",IF(I43<=8/24,"","Error"))),"")
    Attached Files Attached Files
    Last edited by JohnTopley; 12-03-2016 at 07:48 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Introduction
    By ZeeLee in forum Hello..Introduce yourself
    Replies: 1
    Last Post: 04-06-2016, 01:09 AM
  2. [SOLVED] Sum Formula based on single or multiple critera that sums accross and array
    By Dial1 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-27-2013, 07:14 PM
  3. [SOLVED] Cumulative sums
    By kipronopaul in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-11-2012, 08:21 AM
  4. cumulative sums
    By Icarni in forum Excel General
    Replies: 6
    Last Post: 11-02-2009, 10:41 AM
  5. Help regarding cumulative sums
    By karaflas01 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-30-2008, 09:30 AM
  6. Cumulative Sums in Pivot Tables
    By Laura in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-11-2006, 02:00 PM

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