+ Reply to Thread
Results 1 to 8 of 8

Average Top 50 Percentile Values in an Array

Hybrid View

  1. #1
    Registered User
    Join Date
    05-27-2008
    Posts
    28

    Average Top 50 Percentile Values in an Array

    I'm trying to figure out a formula that will find the average of the top 50th percentile of a data set.

    Example:
    Data Set:
    1
    2
    3
    4
    5
    6

    Top 50th percentile {4,5,6}
    average(4,5,6)=5

    There is an excel formula "percentile" but it only returns the 50th percentile value, not a data set that I can average.

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

    Re: Average Top 50 Percentile Values in an Array

    =sumif(a1:a6,">="&percentile(a1:a6,0.5))/countif(a1:a6,">="&percentile(a1:a6,0.5))
    if you have excel 2007 or later
    =AVERAGEIF(A1:A6,">="&PERCENTILE(A1:A6,0.5),A1:A6)
    Last edited by martindwilson; 04-10-2014 at 06:32 AM.
    "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

  3. #3
    Forum Expert Ace_XL's Avatar
    Join Date
    06-04-2012
    Location
    UAE
    MS-Off Ver
    2016
    Posts
    6,074

    Re: Average Top 50 Percentile Values in an Array

    With martin's AVERAGEIF formula, the average range is optional. Hence,

    =AVERAGEIF(A1:A6,">="&PERCENTILE(A1:A6,0.5))
    Life's a spreadsheet, Excel!
    Say thanks, Click *

  4. #4
    Registered User
    Join Date
    05-27-2008
    Posts
    28

    Re: Average Top 50 Percentile Values in an Array

    Thanks you guys, that is what I was looking for. I did find an instance where it was not returning the expected result though. For example if the data set is {2,1,0,0,0,0} then this formula will return the result "0.5" but what I would like it to return would be the value "1" (it is taking the average of all the values since the 50th percentile is "0" instead of just the first three like I would like). Could I use a different formula to just take the average of the top half of the values instead of >= 50th percentile? The numbers might not be in order so that might make it more challenging. What do you think?

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

    Re: Average Top 50 Percentile Values in an Array

    what happens if its an uneven number of values? eg 7 does the top 50% include the middle value or not?
    1234567 do you want the average of 4567 or 567

  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: Average Top 50 Percentile Values in an Array

    one way i can think of
    for case 4567
    =SUMPRODUCT(LARGE($A$1:$A$10,ROW(INDIRECT("1:"&ROUNDUP(COUNTA($A$1:$A$10)/2,0))))/(ROUNDUP(COUNTA($A$1:$A$10)/2,0)))
    for case 567
    =SUMPRODUCT(LARGE($A$1:$A$10,ROW(INDIRECT("1:"&ROUNDDOWN(COUNTA($A$1:$A$10)/2,0))))/(ROUNDDOWN(COUNTA($A$1:$A$10)/2,0)))

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

    Re: Average Top 50 Percentile Values in an Array

    opps a wrong idea

  8. #8
    Registered User
    Join Date
    05-27-2008
    Posts
    28

    Re: Average Top 50 Percentile Values in an Array

    Thanks Martin, that was very helpful.

    I've got one more bonus question on this since you seem to be so good at it . This one could be challenging but here goes. From our ERP system we can get a report that shows the quantity of product shipped by customer by month. From this I would like to be able to find the average for each customer, the average for the month, and the average for the top 50% in a month (using the logic in your second set of formulas).

    The one challenging part to it is that our ERP system won't return a zero value if there are no sales in a given month, it will instead return a blank cell. This is problematic because you might have a new customer come in three months ago and his monthly sales quantity will be {2,0,2} but the six month report will show {-,-,-,2,-,2} and I would only want to take the average of {2,0,2}. I've attached a sample worksheet of how the data could look. The green cells are cells that I would want used in the calculation and the white ones I would not, the yellow ones are where the results would show. What do you think?

    Sample Average Worksheet.xlsx

+ 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. Conditional array/percentile
    By fack7960 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-08-2014, 09:04 PM
  2. [SOLVED] Non array alternative for percentile function
    By vandan_tanna in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2012, 11:43 AM
  3. array calculation and percentile
    By ianbec in forum Excel General
    Replies: 2
    Last Post: 06-16-2011, 01:50 AM
  4. PERCENTILE Using Array Formula
    By Azad in forum Excel General
    Replies: 4
    Last Post: 05-04-2010, 03:48 AM
  5. array problem in Percentile function
    By mingali in forum Excel General
    Replies: 1
    Last Post: 04-07-2010, 03:39 AM

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