+ Reply to Thread
Results 1 to 9 of 9

SUM between upper and lower ranges of cumulative figures

  1. #1
    Registered User
    Join Date
    06-18-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    23

    SUM between upper and lower ranges of cumulative figures

    Dear All,

    This is my first post to the forum, so I hope I have followed all the rules.

    I hope it is possible that you could help me with the following problem. This has been bugging me for some time now.

    I have a table that lists days spent on an activity by month (D7:D17). The next column keeps a running total of these days (E7:E17). From the cumulative totals (E7:E17) I need to split the days into categories of 0 to 45 days, 46 to 60 days and finally 61+ days.

    I have managed to use formulae to calculate the 0 to 45 days (F7:F17) and 60+ days (N7:H17), based on the cumulative column, but I'm having trouble with the 46 to 60 days formula (G7:G17). I'm hoping a formula can be created that looks at the cumulative days already spent and if the cumulative days up to that month are over 45 days but less than 60, it will add in the days within that range for the month in question.

    I know that the results in the following cells should be:
    G7:G9 = all 0
    G10 = 2
    G11 = 0
    G12 = 13
    G13:G17 = all 0
    Total (cell G18)= 15 days

    At the top of the table there are some input boxes (E2:H4). I'd hope that the formula can reference these cells so if the need to change the ranges occurs, I can simply change these cells.

    I have enclosed the Excel file with the table.

    Any help that can be offered would be most appreciated.

    Regards,

    David

    Cumulative day ranges.xlsx

  2. #2
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,739

    Re: SUM between upper and lower ranges of cumulative figures

    you can use an AND to test if the dates are within a range
    =IF(AND(E7>=$G$2,E7<=$G$3)

    which may help with the next section you need to count

    but was not sure what you then wanted to do as a calculation to add the days in

    so 47 days - 33 makes 14 days - not 15
    and did not follow the

    G7:G9 = all 0
    G10 = 2
    G11 = 0
    G12 = 13
    G13:G17 = all 0
    Total (cell G18)= 15 days

    sorry - can you explain the logic a bit further

    ok - i think i may have the logic - need to think again

    this is very dependant on your layout
    =IF(NOT(ISNUMBER(E6)),0,IF(AND(SUM($D$7:D7)>=$G$2,SUM($D$7:D7)<=$G$3,E7-E6>0),E7-($G$2-1),IF(E7>$G$3,IF(E6<$G$3,($G$3)-E6,0),0)))

    I had to subtract one from the lower limit - so that 47 would = 2 as required - is that correct ?
    Last edited by etaf; 06-18-2013 at 10:04 AM.

  3. #3
    Registered User
    Join Date
    06-18-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: SUM between upper and lower ranges of cumulative figures

    Dear etaf,

    Thanks for looking into this. Please let me know if you need any further info.

  4. #4
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,739

    Re: SUM between upper and lower ranges of cumulative figures

    i edited my post - and supplied a revised formula

    =IF(NOT(ISNUMBER(E6)),0,IF(AND(SUM($D$7:D7)>=$G$2,SUM($D$7:D7)<=$G$3,E7-E6>0),E7-($G$2-1),IF(E7>$G$3,IF(E6<$G$3,($G$3)-E6,0),0)))

    I had to change the test on G2 - to G2-1 so that the 47 would read as 2 and the 46 counted as a day

    as i need to check if the previous cumulation a number - and so in the first row that would be the header I used
    IF(NOT(ISNUMBER(E6)),0
    to stop an error returnin g

    next
    ,IF(AND(SUM($D$7:D7)>=$G$2,SUM($D$7:D7)<=$G$3,E7-E6>0)

    is the days between the limits AND(SUM($D$7:D7)>=$G$2,SUM($D$7:D7)<=$G$3
    and is the previous cumulation of days already been assigned ie the difference would be zero - so greater than zero
    E7-E6>0
    if so then we are between the limits and need to calculate another value
    E7-($G$2-1)

    if we are outside the upper limit - we still may need a value - if the previous calc was below the upper limit
    IF(E7>$G$3,IF(E6<$G$3,($G$3)-E6,0),0))) - then we need to test if the previous cumulation days are below the upper limit - if not then we need to calculate that value
    ($G$3)-E6 - which as the days are above the upper limit it will be the upper limit minus the previous cumulated days
    if you change G2 and g3 - should still work for those limits
    Last edited by etaf; 06-18-2013 at 10:13 AM.

  5. #5
    Registered User
    Join Date
    06-18-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: SUM between upper and lower ranges of cumulative figures

    Thank you etaf, that works perfectly. I shall now go and try and understand how you did it.


    Also, thank you for the swift response.

  6. #6
    Registered User
    Join Date
    06-18-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: SUM between upper and lower ranges of cumulative figures

    Dear etaf,

    I've been playing with the ranges, changing the 46 to 60 days to 46 to 75 days. Once the 75 days is input in cell G3, the total for the 46 to 75 days column totals 32. This should be 30 days (28 days in cell G12). It appears to be adding addtional days and I can't see why this is so.

    Do you have any recommendations to solve this?

    Your help is most appreciated.

  7. #7
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,739

    Re: SUM between upper and lower ranges of cumulative figures

    =IF(NOT(ISNUMBER(E11)),0,IF(AND(SUM($D$7:D12)>=$G$2,SUM($D$7:D12)<$G$3,E12-E11>0),E12-($G$2-1),IF(E12>=$G$3,IF(E11<$G$3,($G$3)-E11,0),0)))

    I changed an = to , because - if the value in E = the upperlimit - it was taken the lower limit

    following the rules
    =75-47 = 28

    so it maybe the actual counting of the days - so if day 75 is to be counted -

    it maybe the whole thing needs to be rethought out

    so on the lower limit
    ,E7-($G$2-1)

    So we count the lower limit day 46 as 1 ($G$2-1)

    if i then add 1 to the upper limit to include the 75 day
    ($G$3+1)-E11
    it does not work for your 13 example

    I guess these calculations maybe all wrong

  8. #8
    Registered User
    Join Date
    06-18-2013
    Location
    UK
    MS-Off Ver
    Excel 2010
    Posts
    23

    Re: SUM between upper and lower ranges of cumulative figures

    Hi etaf,

    I've had a look through your amazing formula and I think I've found a quick fix. I'm sure there is a much better way of doing it, but I'm hoping this inelegant add in will suffice.

    Using your original formula, added in the following:

    =IF(NOT(ISNUMBER(E6)),0,IF(AND(SUM($D$7:D7)>=$G$2,SUM($D$7:D7)<=$G$3,E7-E6>0),E7-($G$2-1)-(SUMG6:G7),IF(E7>$G$3,IF(E6<$G$3,($G$3)-E6,0),0)))

    I believe that E7-($G$2-1) is taking the whole range between 46 and 60 days. By adding in the -(SUMG6:G7) this takes out those days within the 46 to 60 days that have already been counted. I copied down the column and it seems to work.

    Many thanks for your help with this problem.

  9. #9
    Forum Expert etaf's Avatar
    Join Date
    10-22-2004
    Location
    Wittering, West Sussex, UK
    MS-Off Ver
    365 (Mac OSX) (16.83 (24031120))
    Posts
    8,739

    Re: SUM between upper and lower ranges of cumulative figures

    your welcome, glad to have got you started
    hopefully it works for all variations

+ 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