+ Reply to Thread
Results 1 to 19 of 19

Need to Average highest continuous 30 daily values over past 48 month span

  1. #1
    Registered User
    Join Date
    04-24-2013
    Location
    Northern Virginia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Need to Average highest continuous 30 daily values over past 48 month span

    Afternoon,

    After spending the last week trying to work this out and not finding the exact solution on the web I have decided to appeal to the masters. I have spreadsheet with years of daily data. Every month I will add that month's daily values. I need to return the average values for the highest 30 values in a row over the last 48 month period. Years ago we had a q basic program that did this. Full disclosure I don't use VBA. Is there a formula to do this? Thanks in advance.

  2. #2
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Can you provide a mock file with example data so we can see your layout please. Make sure the data does not contain anything sensitive.
    Also make sure you provide enough data for us to work with (you want highest 30 values so provide 50ish please) and also include the result expected for this data manually entered (if you can highlight in a colour to stand out so we can see clearly where the results are). To upload a file click Go Advanced then select Manage Attachments.

    Will the period you are checking over always be the last 48 months or is it possible that this will vary?
    Say thanks, click *

  3. #3
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    I don't think there is a single formula that can calculate that for you but you can use helper calculations.. Assuming your data are in column A you can use column B to calculate the 30 day rolling average. You can then use Max on column B to find your highest 30 day period.

    if you can upload some sample data I'll set it up for you..
    Elegant Simplicity............. Not Always

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Assuming A1 is a header, and there are 1060 rows of data below,

    =MAX(SUBTOTAL(9, OFFSET(A1, ROW(INDIRECT("1:1060")), 0, 30, 1)))

    The formula MUST be confirmed with Ctrl+Shift+Enter instead of just Enter.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Registered User
    Join Date
    04-24-2013
    Location
    Northern Virginia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    I have attached the file as requested. It will always look at the past 48 months and return the highest consecutive 30 values as an average. In the attached sheets I have included the result the program generated last month. The main spreadsheet (not attached) will have data going back further than the 48 months and I will add a month's data every month and then rerun the data. Thanks.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    I make the solution 16.33786 on the 19/03/2010


    example (11).xlsx

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    In D2,

    =MAX(SUBTOTAL(9, OFFSET(B1, ROW(INDIRECT("1:1060")), 0, 30, 1)))/30

    ... confirmed with Ctrl+Shift+Enter

    @ Andy: Your formula is only averaging 29 days.

  8. #8
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Thank you for the correction

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

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Quote Originally Posted by shg View Post
    =MAX(SUBTOTAL(9, OFFSET(B1, ROW(INDIRECT("1:1060")), 0, 30, 1)))/30
    I think you probably need to extend the range to get the full 4 years......but given shg's formula in D2 to get the high average you can use this formula for the start date of that 30 day period

    =INDEX(A2:A1462,MATCH(D2*30,SUBTOTAL(9,OFFSET(B1, ROW(INDIRECT("1:1461")),0,30)),0))

    Confirmed with CTRL+SHIFT+ENTER and formatted as a date

    I get 17th Feb 2010
    Last edited by daddylonglegs; 04-26-2013 at 06:05 PM.
    Audere est facere

  10. #10
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    example (11) (1).xlsx

    . Sorry but I disagree... I've charted the data which points to mid March with a 30 day max average of 16.255.

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

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    I think it's the same thing really, Andy - the start date of the 30 day period is 17th Feb 2010 - so the end date is mid-March, 18th to be precise

    Because you are using MROUND that will make my formula for the date give an error but based on your value in C1 you can still do it with

    =INDEX(A2:A1493,MATCH(C1,MROUND(SUBTOTAL(9,OFFSET(B1, ROW(INDIRECT("1:1492")),0,30))/30,0.001),0))

    That will give 17th Feb, i.e. the start date of the 30 day period with the greatest combined value, clearly you could add 29 to get the end date - that would match your results

  12. #12
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Damn - LOL......... I bow to your superiority

  13. #13
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    In practice, I'd be inclined to use Andy's approach -- it's a lot lighter weight, and non-volatile.

  14. #14
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    The range of cells of the highest 30 day average is from Feb 17,2010 to Mar 18, 2010 inclusive. The average for that range is 16.25491

    My methodology was not elegant like the above formulae but it was effective.

    I entered in cell C30 =AVERAGE(B1:B30) and copied this down the length of the data to give a running AVERAGE of 30 cells in column B. I then in D30 entered =RANK(C30,$C$30:$C$1060)

    I found number 1 in column D and that was the end of the range of highest average.
    Last edited by newdoverman; 04-26-2013 at 09:26 PM.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    That's a workable solution, good job.

  16. #16
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Being entirely self-taught, sometimes solutions come the "long way around".

    Thanks

  17. #17
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Me too ......................There is usually one perfect solution to a problem and about 10 different workarounds... To be perfectly honest, as far as i'm concerned anything that works is good

  18. #18
    Registered User
    Join Date
    04-24-2013
    Location
    Northern Virginia
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Brillant. Thank you so much I am still learning how powerful a tool excel can be. Wow you guys are great. I am sure that I will be back. I hope you all had a great weekend. I even double checked with past data and it matched. Great Work.

  19. #19
    Valued Forum Contributor
    Join Date
    03-29-2013
    Location
    United Kingdom
    MS-Off Ver
    Office/Excel 2013
    Posts
    1,749

    Re: Need to Average highest continuous 30 daily values over past 48 month span

    Glad to hear it Bill..........
    Can you mark the thread as solved mate ... It's at the top of the thread under the thread tools menu

+ 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