+ Reply to Thread
Results 1 to 9 of 9

Average most recent 3 values excluding dashes - array formula help required

  1. #1
    Registered User
    Join Date
    09-29-2007
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    55

    Average most recent 3 values excluding dashes - array formula help required

    Howdy,

    I have a range of 10 cells A1:J1 that are progressively filled with scores each week. I am trying to determine the average of the most recent 3 scores and while researching I found a formula that does almost exactly what I need. It's an array formula and they are a weakness of mine as I rarely have cause to use them. I'm having difficulty adapting this, or even understanding whether this is something that can be achieved with this formula.

    {=AVERAGE(INDEX(A1:J1,LARGE(IF(A1:J1<>"",COLUMN(A1:J1)-COLUMN(A1)+1),3)):J1)}

    This formula is perfect except for one thing. The values will sometimes contain a dash which just means no score. These are different from blank cells which will always be on the right side waiting to be filled whereas the dashes will be mixed in with the scores. I am trying to get the average of the most recent 3 scores while ignoring the dashes. So if the first 6 values [edit - the only 6 values, which would be stored in A1:F1] are 20 30 40 - - 50, the average would be (30,40,50) = 40, not (-,-,50) = 50. As far as I can tell, getting this formula to reference B1:J1 (30 40 - - 50 [and four blanks]) in the example would be OK but at the moment it references D1:J1.

    I have considered trying to add a COUNTIF for the dashes in the resulting range and using that to make an adjustment but if there are several dashes in a row I can see the formula getting out of hand. I'm sure there is a more elegant way to do it but I haven't even figured out the logic yet let alone a way to implement it. I'm keen to learn about arrays but this is definitely beyond me at the moment.

    Any help or suggestions would be appreciated!
    Last edited by cricket_stoner; 04-03-2017 at 07:31 AM. Reason: Clarity

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

    Re: Average most recent 3 values excluding dashes - array formula help required

    Try:
    Please Login or Register  to view this content.
    Ctrl-shift-enter
    Quang PT

  3. #3
    Registered User
    Join Date
    09-29-2007
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    55

    Re: Average most recent 3 values excluding dashes - array formula help required

    Thanks for the response Bebo.

    This isn't quite right but it's close. It works if the range is full of scores and dashes, but if there are blank cells then it counts them as zeros which impacts on the average. The formula I posted seems to treat them as blanks which therefore don't impact on the average.

    At any time, there may only be, say, 7 scores (or dashes) in the range of 10 cells. These seven values or dashes would always be A1:G1 (i.e. values/dashes are always added in the leftmost blank cell.) This formula counts the remaining 3 blank cells (H1:J1) as zeros.

    Thanks for your help and apologies if my explanation caused the confusion.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,206

    Re: Average most recent 3 values excluding dashes - array formula help required

    If the dashes can be replaced by a score of 0 and cells formatted as:

    ##0_-; ##0_-;"-"_-;_-@_-

    then

    =AVERAGE(IF(COLUMN(A1:J1)>=LARGE(IF(A1:J1,COLUMN(A1:J1)),3),IF(A1:J1,A1:J1)))

    Entered with Ctrl+Shift+Enter

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

    Re: Average most recent 3 values excluding dashes - array formula help required

    Quote Originally Posted by cricket_stoner View Post
    {=AVERAGE(INDEX(A1:J1,LARGE(IF(A1:J1<>"",COLUMN(A1:J1)-COLUMN(A1)+1),3)):J1)}
    Assuming there will always be 3 numbers to average...

    Replace: A1:J1<>""

    With: ISNUMBER(A1:J1)

    Still array entered.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  6. #6
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Average most recent 3 values excluding dashes - array formula help required

    Hi


    =SUM(INDEX(A1:J1,AGGREGATE(14,6,COLUMN(A:J)/ISNUMBER(A1:J1),INDEX(ROW(1:3),0))))/3

    I've to adjust the denominator.

    Just for sharing some idea.
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  7. #7
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Average most recent 3 values excluding dashes - array formula help required

    Hi All


    a little fix, if count of numbers could be lesser than 3

    =IFERROR(SUM(INDEX(A1:J1,AGGREGATE(14,6,COLUMN(A:J)/ISNUMBER(A1:J1),INDEX(ROW($1:$3),0))))/3,AVERAGE(A1:J1))

    Regards

  8. #8
    Registered User
    Join Date
    09-29-2007
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    55

    Re: Average most recent 3 values excluding dashes - array formula help required

    Thanks for the replies!!

    John, the dashes represent no score, which should be skipped in the averages, and zeros represent a score of zero which should be included in the averages.

    Tony, spot on! Thanks so much.

    canapone, this is also perfect. I'm intrigued as it's not an array formula but I see that AGGREGATE is treated in a similar fashion when I use Evaluate Formula. Many thanks for also accounting for scenarios where there are less than 3 scores. In this example it's not necessary however I am saving it for future reference.

    Thanks to all of you for your help!

  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 most recent 3 values excluding dashes - array formula help required

    You're welcome. We appreciate the feedback!

+ 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 every other row excluding 0 values
    By redguy44 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-02-2016, 02:13 PM
  2. Replies: 1
    Last Post: 03-24-2015, 01:42 PM
  3. Replies: 13
    Last Post: 10-08-2014, 08:35 AM
  4. Average of selected cells, array required?
    By oscar munero in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-12-2013, 05:39 PM
  5. Array average excluding zeros
    By ChrisNor in forum Excel General
    Replies: 5
    Last Post: 12-06-2010, 08:55 AM
  6. Replies: 4
    Last Post: 12-24-2008, 02:53 AM
  7. Average excluding negative values
    By tangomj in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-20-2007, 02:27 PM

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