+ Reply to Thread
Results 1 to 17 of 17

Summing 3 Rows, then finding the Highest average

  1. #1
    Registered User
    Join Date
    06-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    44

    Summing 3 Rows, then finding the Highest average

    I want to return the highest averages from a sum of a 3 row period, as below:

    Data.PNG

    Data2.PNG

    Data3.PNG

    Data4.PNG

    Is it possible for an array formula to do the work of cells C,D,E with offset, index etc, showing the highest average?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Summing 3 Rows, then finding the Highest average

    Attach a workbook - we can't manipulate a picture.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    06-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    44

    Re: Summing 3 Rows, then finding the Highest average

    Sorry about that, I can't seem to find where to attach the file?

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Summing 3 Rows, then finding the Highest average

    Unfortunately the attachment icon doesn't work at the moment, so to attach an Excel file you have to do the following: just before posting, scroll down to Go Advanced and then scroll down to Manage Attachments. Now follow the instructions at the top of that screen.

  5. #5
    Registered User
    Join Date
    06-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    44

    Re: Summing 3 Rows, then finding the Highest average

    Thanks for the info.

    See attached.
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Summing 3 Rows, then finding the Highest average

    You can get rid of column C thus:

    =SUM(B2:B4)/3

    I am not sure what you want, though, when you say:

    Is it possible for an array formula to do the work of cells C,D,E ...
    What will this look like? Are you wanting to have the highest average marked with Y without seeing the highest average column? If so, why? And also if so, why not just hide the column?

    Excel 2016 (Windows) 32 bit
    A
    B
    D
    1
    Series
    Amount
    Max Average
    2
    1
    40
    3
    2
    23
    4
    3
    40
    Y
    5
    4
    50
    6
    5
    65
    7
    6
    30
    8
    7
    10
    9
    8
    20
    10
    9
    23
    11
    10
    40
    Sheet: Sheet1
    Last edited by AliGW; 09-09-2018 at 03:15 AM.

  7. #7
    Registered User
    Join Date
    06-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    44

    Re: Summing 3 Rows, then finding the Highest average

    Yes, I could hide the column. It was more wanting to know if this was possible in an array.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Summing 3 Rows, then finding the Highest average

    If it is, I think it will be quite complex and possibly processor heavy, especially if your real dataset is large. As a theoretical question, it will be interesting to see if it can be done, but as a practical solution ...? Not so sure.

    The difficulty will be combining a rolling average calculation with a fixed range maximum calculation.

    Let's see if the array formula wizards here can crack it.
    Last edited by AliGW; 09-09-2018 at 03:29 AM.

  9. #9
    Forum Expert tim201110's Avatar
    Join Date
    10-23-2011
    Location
    Russia
    MS-Off Ver
    2016, 2019
    Posts
    2,357

    Re: Summing 3 Rows, then finding the Highest average

    as a way
    UDF
    Please Login or Register  to view this content.
    Attached Files Attached Files

  10. #10
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Summing 3 Rows, then finding the Highest average

    Is this what you want?

    =MAX(SUBTOTAL(1,OFFSET(B2,ROW(B2:B11)-ROW(B2),0,3,1)))

    ...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.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Summing 3 Rows, then finding the Highest average

    That seems to work as a normal formula, Jason, without array-entering.

    I think what the OP wants is for the formula to determine whether the row its' on is the one returning the maximum, and if so, return "Y".

    PS Needs to be this, as the last two rows' results are not quite right with the formula in post #10:

    =MAX(SUBTOTAL(9,OFFSET(B2,ROW(B2:B11)-ROW(B2),0,3,1))/3)
    Last edited by AliGW; 09-09-2018 at 08:34 AM.

  12. #12
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Summing 3 Rows, then finding the Highest average

    At a glance, it looks like it works without array confirming, but it only gets the average of B2:B5, none of the other ranges are evaluated.

    Quote Originally Posted by AliGW View Post
    PS Needs to be this, as the last two rows' results are not quite right with the formula in post #10:
    But are the results correct, Ali?

    The OP has asked for average of 3, but the last 2 results are false because there are less than 3 values to average.

    This one gives the right result

    =IF(SUM(B2:B5)/3=MAX(SUBTOTAL(9,OFFSET($B$2,ROW($B$2:$B$11)-ROW($B$2),0,3,1))/3),"Y","")

    and this one gives the correct result.

    =IF(SUM(B2:B5)/3=MAX(SUBTOTAL(1,OFFSET($B$2,ROW($B$2:$B$11)-ROW($B$2),0,3,1))),"Y","")

    Regardless of which, array confirmation is needed before filling down.

  13. #13
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Summing 3 Rows, then finding the Highest average

    I'm working to what the OP presented as the results he wants. Formulae from posts #10 and #11 below (neither array-entered):

    Excel 2016 (Windows) 32 bit
    A
    B
    C
    D
    E
    F
    1
    Series
    Amount
    Average of 3
    Max Average
    Ali
    Jason
    2
    1
    40
    34.33333333
    34.3333333
    34.33333
    3
    2
    23
    37.66666667
    37.6666667
    37.66667
    4
    3
    40
    51.66666667
    Y
    51.6666667
    51.66667
    5
    4
    50
    48.33333333
    48.3333333
    48.33333
    6
    5
    65
    35
    35
    35
    7
    6
    30
    20
    20
    20
    8
    7
    10
    17.66666667
    17.6666667
    17.66667
    9
    8
    20
    27.66666667
    27.6666667
    27.66667
    10
    9
    23
    21
    21
    31.5
    11
    10
    40
    13.33333333
    13.3333333
    40
    Sheet: Sheet1

  14. #14
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Summing 3 Rows, then finding the Highest average

    Originaly that was a single cell formula to give the max average without filling down. If you enter it and array confirm, this is what it gives you, 51.66666667

    Now realising that they still want the Y flag column to highlight the row, I've modified the formula in post #12 to compare the average for each group of 3 to the average for all groups of 3 and fag the row that contains the max average without the other columns.

    Enter either formula form post 12, in D2 and fill down (array confirmed, you get Y in the right place, not array confirmed, you don't).

  15. #15
    Registered User
    Join Date
    06-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    44

    Re: Summing 3 Rows, then finding the Highest average

    Thanks Ali and Jason. I'd never thought out using Subtotal.

    I've modified the range B2:B5 to B2:B4 in Jasons formula which returns the same result I was after.

  16. #16
    Registered User
    Join Date
    06-08-2015
    Location
    Australia
    MS-Off Ver
    2013
    Posts
    44

    Re: Summing 3 Rows, then finding the Highest average

    Thanks Tim.

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,779

    Re: Summing 3 Rows, then finding the Highest average

    I presume you used the SUBTOTAL 9 option?

+ 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] Need to select earliest five rows matching highest value, and next highest if not enough
    By Ochimus in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 05-05-2016, 11:26 AM
  2. [SOLVED] Finding Average two consecutive rows in a column
    By windme in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-28-2013, 11:53 AM
  3. [SOLVED] Finding an Average of every 25 rows.
    By rtb1991 in forum Excel General
    Replies: 9
    Last Post: 11-12-2012, 03:53 PM
  4. Replies: 3
    Last Post: 06-27-2012, 10:12 PM
  5. Replies: 4
    Last Post: 10-08-2010, 04:18 AM
  6. Replies: 3
    Last Post: 08-10-2006, 11:40 PM
  7. [SOLVED] Summing & return highest value
    By PSU35 in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-31-2006, 02:45 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