+ Reply to Thread
Results 1 to 10 of 10

Rolling average calculation (WTD)

  1. #1
    Registered User
    Join Date
    10-10-2010
    Location
    Cleethorpes
    MS-Off Ver
    Excel 2000
    Posts
    3

    Rolling average calculation (WTD)

    I'm stuck and need a little help.

    I am trying to create a formula that calculates an average over a rolling 119 day period

    The problem that I have, is that I need it to ignore certain days.

    I see two ways to achieve this but cant seem to get it right.


    1, should a cell have a value of (A/L) or (sick) I need the calculation to ignore these days from the reference period.

    2, For every (A/L) or (sick) it should extend the ref period by the same number.....for example : should a member of staff take 7 A/L days the ref period extends to 126 days


    any clues ?
    Last edited by fredy_1972; 10-11-2010 at 08:11 AM.

  2. #2
    Forum Contributor Charlie_Howell's Avatar
    Join Date
    09-27-2010
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2007
    Posts
    218

    Re: Rolling average calculation (WTD)

    upload an example for us to look at and I'm sure one of these excel wizards will come up with something clever.

  3. #3
    Registered User
    Join Date
    10-10-2010
    Location
    Cleethorpes
    MS-Off Ver
    Excel 2000
    Posts
    3

    Re: Rolling average calculation (WTD)

    I have attached a crude example.


    If you look at cell B108 to B112 - staff member books 5 days A/L

    Because of the A/L, I need for example, C134 to extend back another 5 days.


    I would like a formula that would do this automatically
    Attached Files Attached Files

  4. #4
    Forum Contributor Charlie_Howell's Avatar
    Join Date
    09-27-2010
    Location
    Memphis, TN
    MS-Off Ver
    Excel 2007
    Posts
    218

    Re: Rolling average calculation (WTD)

    try this and let me knw if it helps
    Attached Files Attached Files

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Rolling average calculation (WTD)

    Might be barking up the wrong tree but if you're saying each daily sum should reference the last 119 valid days (be they blank/hours) then perhaps:

    Please Login or Register  to view this content.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Rolling average calculation (WTD)

    Hi Fredy_1972,

    So you need to add all the hours worked in the last 119 days that were worked. You toss out all weekends and Sick and A/L days. I had this great formula to count all the A/L plus Sick days in the last 119 days and make the range start further up your range to calculate it correctly. Then it occured to me what if the extended range backwards included some Sick or A/L days. I'd need to count them too. Recursion...

    I'd suggest this solution: Sort the Date and Hours (together) using a Z->A sort by Date. Then filter to only show Hours that are greater than Zero. Then Sum the Hours down 119 rows and this is your total hours worked 119 days where hours were worked.

    Does this process (not formula) solve your question?
    Last edited by MarvinP; 10-10-2010 at 02:03 PM.

  7. #7
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Rolling average calculation (WTD)

    Quote Originally Posted by MarvinP View Post
    I had this great formula to count all the A/L plus Sick days in the last 119 days and make the range start further up your range to calculate it correctly. Then it occured to me what if the extended range backwards included some Sick or A/L days. I'd need to count them too. Recursion...
    Not really sure it's a recursive calculation per se.
    As I see things it is just a matter of identifying where - working from "current" date backwards - the 119th "non-text" instance occurred. Then simply a case of summing from that row to the "current" row.
    (this is the approach highlighted in the prior array)

    FWIW, I wouldn't argue that a multitude of arrays is desirable ...

  8. #8
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Rolling average calculation (WTD)

    You're making me study some more. I'm getting better at CSE formulas. Now I have to examine the one above.

    And thanks for the education.

  9. #9
    Registered User
    Join Date
    10-10-2010
    Location
    Cleethorpes
    MS-Off Ver
    Excel 2000
    Posts
    3

    Re: Rolling average calculation (WTD)

    Thanks for your suggestions all.

    DonkeyOte nailed it. I dont understand it but it works like a charm

    Thanks

  10. #10
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,169

    Re: Rolling average calculation (WTD)

    I spent about an hour this morning trying to understand DO's CSE formula above. I got close and then realized there are at least two other ways to solve this problem.

    Using Advanced Filters, one could simply filter out the Sick or A/L hour days Reverse Sort by Date and sum the Next 119 days of hours. See Attached

    Using Pivot Tables the same scheme is used. Pivot table the data and use the Hours to Sum and Filter. Filter out the A/L and any other non-numeric notations. Then Sort from Newest to Oldest and sum the next 119 remaining rows in the pivot table.

    I love the line "There are many ways to solve a problem - just pick one!"

    I understand advanced filters and pivot tables better than CSE Array Formulas. Who's right? We both are. (I should be carrying DO's sword to fight the windmills in most of these formula battles.)

    The method you use should make sense to YOU. Sometimes its easier to understand when done in parts.

    Example:
    Add 1+2+3+4+...+199+200. Do it in your head.
    Same problem is 1+200+2+199+3+198+.....+100+101.
    This is 100 x 201 = 20100

    I'll climb down off my soapbox and do some real work now.

+ 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