+ Reply to Thread
Results 1 to 13 of 13

Grouped numbers average

  1. #1
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Grouped numbers average

    Hello again guys!

    Please help me with another challenge I have.
    I need to calculate the average of 3 numbers. Three numbers out of four. The forth number should be excluded from the average calculation by its 'distance' from the other 3.
    For ex:
    1 2 3 9 -> the average will have to be 2 (9 is excluded because it's too far from the 123 group)
    2 12 14 16 -> the average will have to be 14 (2 is excluded because it's too far from the 12 13 14 group)

    Or see the attached file.

    Thank you!
    Attached Files Attached Files
    .. and don't forget to have fun!
    Bogdan.

    mark SOLVED and Add Reputation if my answer pleases you

  2. #2
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Grouped numbers average

    Please try

    =AVERAGEIFS(E5:H5,E5:H5,"<>"&AVERAGE(E5:H5)-MAX(ABS(E5:H5-AVERAGE(E5:H5))),E5:H5,"<>"&AVERAGE(E5:H5)+MAX(ABS(E5:H5-AVERAGE(E5:H5))))

    or
    =AVERAGEIFS(E5:H5,$E$4:$H$4,"<>*"&MATCH(MAX(ABS(E5:H5-AVERAGE(E5:H5))),ABS(E5:H5-AVERAGE(E5:H5)),))
    Attached Files Attached Files

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Grouped numbers average

    Or:

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Grouped numbers average

    Thank you both guys for your quick reply!
    The formula that best suits my desired results is Bo_Ry's second formula
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Unfortunately this formula uses the header range and I don't have such info. In the attach was there only for info.
    Ive tried to replace that range with a static array like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    but no success (yes I used Ctrl+Shift+Enter)
    Any ideea?
    Thanks again!

  5. #5
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Grouped numbers average

    AVERAGEIFS , COUNTIFS, SUMIFS cannot use data from array. All data range need to be from range.

    You may try this.

    =AVERAGEIFS(E5:H5,$E$4:$H$4,"<>"&INDEX($E$4:$H$4,MATCH(MAX(ABS(E5:H5-AVERAGE(E5:H5))),ABS(E5:H5-AVERAGE(E5:H5)),)))

  6. #6
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: Grouped numbers average

    Another option:

    =SUM(LARGE(E5:H5,{1,2,3}+(MMULT({-1,1},MMULT(LARGE(E5:H5,{1,2;3,4}),{1;-1}))<0)))/3

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  7. #7
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Grouped numbers average

    @Bo_Ry unfortunatelly your formula has some error, it cannot be pasted ($E€3.39 ??)

    @XOR LX thank you, that formula is beautiful, just one more thing:

    In case the 4 values are homogenuous (0 50 0 50), Bo_Ry's formula takes into average the LAST 3 values (50 0 50) which is exactly what I want!
    You think you can do that?
    Thanks again!

  8. #8
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Grouped numbers average

    One way:

    =AVERAGE(LARGE(E5:H5,{1,2,3}+(AVERAGE(LARGE(E5:H5,{1,4}))>AVERAGE(E5:H5))))

  9. #9
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Grouped numbers average

    Thank you Phuocam.
    Your formula works fine but it returns the average of the first 3 numbers in case of homogeneity. I need the last 3 values.
    As in
    0 50 0 50 the average should be 33.33 and
    50 0 50 0 the average should be 16.67

  10. #10
    Forum Guru
    Join Date
    02-27-2016
    Location
    Vietnam
    MS-Off Ver
    2016
    Posts
    5,910

    Re: Grouped numbers average

    Edit:

    =IF(AVERAGE(LARGE(E5:H5,{1,4}))=AVERAGE(E5:H5),AVERAGE(F5:H5),
    AVERAGE(LARGE(E5:H5,{1,2,3}+(AVERAGE(LARGE(E5:H5,{1,4}))>AVERAGE(E5:H5)))))

  11. #11
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Grouped numbers average

    How about

    =SUM(E5:H5*({1,2,3,4}<>MATCH(MAX(ABS(E5:H5-AVERAGE(E5:H5))),ABS(E5:H5-AVERAGE(E5:H5)),)))/3

  12. #12
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,742

    Re: Grouped numbers average

    Quote Originally Posted by bulina2k View Post
    0 50 0 50 the average should be 33.33 and
    50 0 50 0 the average should be 16.67
    Why? Is it any extra rule about position in set.
    Last edited by KOKOSEK; 08-14-2020 at 12:10 PM.

  13. #13
    Valued Forum Contributor bulina2k's Avatar
    Join Date
    11-20-2012
    Location
    Urziceni, Ialomita, Romania
    MS-Off Ver
    2019 and 365
    Posts
    861

    Re: Grouped numbers average

    Yes, it is an extra rule but these numbers are daily quantities and that's why I need the last 3 days average..
    Thank you all very much guys!
    You've been great! (again!!)

+ 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] How to calculate grouped numbers?
    By QuantEdge in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-13-2018, 04:06 PM
  2. Random numbers evenly grouped
    By mainemojo in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-03-2017, 11:05 AM
  3. Pivot Field Calc: average win for grouped data
    By michellepace in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 12-09-2015, 12:25 PM
  4. Pivot table - average of grouped sum
    By is49460 in forum Excel General
    Replies: 2
    Last Post: 10-19-2011, 03:10 AM
  5. Replies: 2
    Last Post: 06-22-2011, 07:04 PM
  6. Daily Average grouped by Julian Week
    By XANADU79 in forum Excel General
    Replies: 2
    Last Post: 06-07-2011, 10:28 PM
  7. [SOLVED] Calculating a Grouped Weighted Average Rate
    By sylink in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-29-2005, 03:06 PM

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