+ Reply to Thread
Results 1 to 7 of 7

Help creating function for running average on growing data range

  1. #1
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Help creating function for running average on growing data range

    hello,

    I'm trying to create a function that will take the average of the last 25% of that data entries in a given range. In my example, I have 30 days of data, cells A1:A30. This data is going to grow on a daily basis so I need a function to be able to automatically adjust. I would like to take the average of the last 25% of this data. Days with blanks do NOT count. Also, taking 25% of numbers will not always give a whole number, so I would just like that to round up to the next whole number. In my example, 25% of 30 is 7.5, round that to 8. So this function would take the average of the last 8 cells that contain data (blank cells do not count). The resulting average would be 91.54 which can go in cell C1

    Thanks
    Attached Files Attached Files

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Help creating function for running average on growing data range

    Possibly an INDEX formula along the lines of this...

    =AVERAGE(INDEX(A:A,MATCH(99999,A:A)-8):INDEX(A:A,MATCH(99999,A:A)))

  3. #3
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Help creating function for running average on growing data range

    I was thinking the same kinda thing. However, is it possible to exchange the 8 for some kind of percentage? In my case 25%...

  4. #4
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,466

    Re: Help creating function for running average on growing data range

    I suggest a helper column (B column).
    See attachment.
    Attached Files Attached Files
    Quang PT

  5. #5
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Help creating function for running average on growing data range

    Possibly...

    =AVERAGE(INDEX(A:A,MATCH(99999,A:A)-INT(0.25*COUNT(A:A))):INDEX(A:A,MATCH(99999,A:A)))

  6. #6
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Help creating function for running average on growing data range

    thanks for the advice guys. Right now what I have is the following: I used a count function in D1 to count the data in column A. In D2 I just multiplied .25 times D1. In D3 i used roundup function of cell D2 to give me a whole number . Then in D4 I used an array formula: =SUM((A1:A100)*(ROW(A1:A100)>LARGE((ROW(A1:A100))*(NOT(ISBLANK(A1:A100))),D3+1)))/D3

    If all this is possible in one function, that could be sweet...

  7. #7
    Registered User
    Join Date
    01-09-2012
    Location
    Minneapolis, Minnesota
    MS-Off Ver
    Excel 2007
    Posts
    54

    Re: Help creating function for running average on growing data range

    Just bumping this thread to see if anyone this morning has any insight. thanks.

+ 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