+ Reply to Thread
Results 1 to 8 of 8

Finding average of last three entries

  1. #1
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Seattle, WA
    MS-Off Ver
    Office 2007
    Posts
    212

    Finding average of last three entries

    on the 'Stats' tab of the attached sample the formula in M3 is designed to display the average of the last two numbers entered in cells P3-AAD3. this was supplied to me by someone on this site, and it works exactly as needed. However, our parameters have changed and now I need M3 to display the average of the last three numbers instead. I've tried to change the formula but it results in an error. The error remains even if I try to change the formula back.
    I would like not only a solution but a bit of a tutorial on the formula used (or a source to find out how it works on my own). Any help is greatly appreciated.

    sample.xlsx


    Brian
    "Laugh? I thought I'd die!"

    Jimbo?

  2. #2
    Forum Expert
    Join Date
    09-01-2012
    Location
    Norway
    MS-Off Ver
    Office 365
    Posts
    2,883

    Re: Finding average of last three entries

    Try this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    This is an array formula, it has to be entered with Ctrl + Shift + Enter. That's the reason it stopped working for you even if you didn't change it, you have to finish it of with Ctrl + Shif + Enter any time you edited it. If you just click in the formula bar and then hit Esc it should be fine but if you hit Enter you ruined it. Then you have to click in the formula bar again and then hit Ctrl + Shift + Enter. If done properly you will see the { } surrounding the formula, it indicates that is now an array formula. You can't enter those brackets manually.
    <----- If you were helped by my posts you can say "Thank you" by clicking the star symbol down to the left

    If the problem is solved, finish of the thread by clicking SOLVED under Thread Tools
    I don't wish to leave you with no answer, yet I sometimes miss posts. If you feel I forgot you, remind me with a PM or just bump the thread.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Finding average of last three entries

    The original formula was set up as an Arrayed formula which is why it's not working any more. I would suggest this substitute (This is not an arrayed formula)
    =AVERAGE(OFFSET(P3,,MATCH(1E+100,P3:AAD3)-3,1,3))

    P3 is the OFFSET Starting point,

    ,, is how many rows you want to offset =0

    MATCH(1E+100,P3:AAD3)-3 is the number of columns you want to move over to a new starting point.

    The MATCH is looking for 100000000000.... (100 zeros) when it doesn't find it, it matches the last number it finds then we subtract 3 from that to get a starting point which is third from the end.

    ,1 is the number of rows you want to include in your result
    3 is the width or # of columns you want included in your result.
    Does that help?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Finding average of last three entries

    =AVERAGE(INDEX(3:3,MATCH(10^99,$O3:$Aad33,1)+COLUMN(N$1)-2):INDEX(3:3,MATCH(10^99,$O3:$Aad3,1)+COLUMN(N$1)))
    will give the average of the last 3
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

  5. #5
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Seattle, WA
    MS-Off Ver
    Office 2007
    Posts
    212

    Re: Finding average of last three entries

    Thanks!
    Both the first two work fine. I will probably go with the one that isn't an array formula for now. Is there a way to modify this to use a variable to determine how many to average?

  6. #6
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: Finding average of last three entries

    =AVERAGE(OFFSET(P3,,MATCH(1E+100,P3:AAD3)-A1,1,3)) where a1 contains the number of last cells you want to average

  7. #7
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Seattle, WA
    MS-Off Ver
    Office 2007
    Posts
    212

    Re: Finding average of last three entries

    Fantastic!
    Thank you again!!

  8. #8
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Finding average of last three entries

    Martin forgot one of the 3's

    =AVERAGE(OFFSET(P3,,MATCH(1E+100,P3:AAD3)-A1,1,A1))

+ 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