+ Reply to Thread
Results 1 to 9 of 9

Average Of Last 3 Values Meeting Criteria

  1. #1
    Registered User
    Join Date
    08-28-2016
    Location
    Bunbury
    MS-Off Ver
    2011 Mac
    Posts
    3

    Average Of Last 3 Values Meeting Criteria

    Hi,
    I am trying to find the average of the most recent 3 values meeting the criteria of pet type.
    In other words, I need the average of the 3 most recent (by date) Dog values, 3 most recent (by date) Cat values etc.

    Apologies, I can't seem to add an attachment. I have pasted the data below.

    Date Animal Value
    1/01/11 Dog 17
    2/03/11 Cat 10
    8/07/11 Cat 7
    8/09/11 Dog 8
    9/01/12 Cat 13
    8/07/12 Bird 9
    6/08/12 Cat 2
    4/07/13 Bird 3
    8/07/13 Dog 20
    5/07/14 Bird 15
    5/08/14 Cat 19
    6/08/14 Cat 16
    8/09/14 Bird 12
    3/05/15 Dog 11
    4/07/15 Dog 5
    6/07/15 Bird 18
    5/09/15 Bird 1
    6/06/16 Dog 14
    6/08/16 Bird 6
    7/08/16 Cat 4
    7/08/16 Dog 7

    Thanks for the help!

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Average Of Last 3 Values Meeting Criteria

    To Attach a File:

    1. Scroll down to the window below your post Additional Options
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 VersionVersion 2501 Win 11
    Posts
    24,423

    Re: Average Of Last 3 Values Meeting Criteria

    To attach a sample workbook.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Average Of Last 3 Values Meeting Criteria

    It looks like the dates are in ascending order so would it be safe to assume we can average the 3 bottom-most numbers for the criteria?

    Will there always be at least 3 instances of the criteria? If not, then what should happen?
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: Average Of Last 3 Values Meeting Criteria

    Enter formula in cell E2 and copy down
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    ***Array formula
    ...confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER.
    You will know the array is active when you see curly braces { } appear around your formula.
    If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.

    v A B C D E
    1 Date Animal Value Unique Names Avg of last 3
    2 1/1/2011 Dog 17 Dog 8.67
    3 2/3/2011 Cat 10 Cat 13.00
    4 8/7/2011 Cat 7 Bird 8.33
    5 8/9/2011 Dog 8
    6 9/1/2012 Cat 13
    7 8/7/2012 Bird 9
    8 6/8/2012 Cat 2
    9 4/7/2013 Bird 3
    10 8/7/2013 Dog 20
    11 5/7/2014 Bird 15
    12 5/8/2014 Cat 19
    13 6/8/2014 Cat 16
    14 8/9/2014 Bird 12
    15 3/5/2015 Dog 11
    16 4/7/2015 Dog 5
    17 6/7/2015 Bird 18
    18 5/9/2015 Bird 1
    19 6/6/2016 Dog 14
    20 6/8/2016 Bird 6
    21 7/8/2016 Cat 4
    22 7/8/2016 Dog 7
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Average Of Last 3 Values Meeting Criteria

    Quote Originally Posted by alkey View Post
    =average(index(c:c,n(if(1,large(index((b$2:b$22=d2)*(row(b$2:b$22)),0),row(indirect("1:3")))))))
    ***array formula
    This looks better
    =AVERAGE(INDEX(C:C,N(IF(1,LARGE(INDEX((B$2:B$22=D2)*(ROW(B$2:B$22)),0),{1,2,3})))))

  7. #7
    Registered User
    Join Date
    08-28-2016
    Location
    Bunbury
    MS-Off Ver
    2011 Mac
    Posts
    3

    Re: Average Of Last 3 Values Meeting Criteria

    Thanks AlKey. Worked great.

  8. #8
    Registered User
    Join Date
    08-28-2016
    Location
    Bunbury
    MS-Off Ver
    2011 Mac
    Posts
    3

    Re: Average Of Last 3 Values Meeting Criteria

    Thanks Tony. Yes the data is or can be sorted into date order. I am curious though, do you have a method if it was not sorted in date order?

  9. #9
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Average Of Last 3 Values Meeting Criteria

    If the data was in random order...

    E2 = some animal

    Array entered**:

    =AVERAGE(IF(A2:A22=LARGE(IF(B2:B22=E2,A2:A22),{1,2,3}),IF(B2:B22=E2,C2:C22)))

    This array formula** entered in

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Average(ifs) meeting certain criteria
    By B7Des in forum Excel General
    Replies: 12
    Last Post: 07-30-2014, 07:28 AM
  2. Excel 2007 : average last 5 values meeting certain criteria
    By jrbdotcom31 in forum Excel General
    Replies: 4
    Last Post: 05-15-2010, 11:47 PM
  3. Average of numbers within a range meeting certain criteria
    By Domenic in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 09-06-2005, 09:05 PM
  4. [SOLVED] Average of numbers within a range meeting certain criteria
    By Domenic in forum Excel Formulas & Functions
    Replies: 20
    Last Post: 09-06-2005, 07:05 PM
  5. [SOLVED] Average of numbers within a range meeting certain criteria
    By opal23k in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 PM
  6. [SOLVED] Average of numbers within a range meeting certain criteria
    By opal23k in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  7. Average of numbers within a range meeting certain criteria
    By opal23k in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 AM

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