Getting average of top 30% of the values in one column

北慕城南 提交于 2020-01-24 15:49:32

问题


I have a column that lists bunch of numbers. How can I select the average of top 30% of the values in one column:

'Values'
10
9
8
7
6
5
4
3
2
1

so, the top 30% is '10, 9, 8' and the average is (10+9+8)/3 = 9


回答1:


In any version of excel you can use either a SUMIF/COUNTIF along the same lines as Sean's suggestion, i.e.

=SUMIF(A1:A10,">"&PERCENTILE(A1:A10,0.7))/COUNTIF(A1:A10,">"&PERCENTILE(A1:A10,0.7))

or a shorter "array formula"

=AVERAGE(IF(A1:A10>PERCENTILE(A1:A10,0.7),A1:A10))

confirmed with CTRL+SHIFT+ENTER

These should all give identical results




回答2:


If you are using excel 2007 or newer, =AVERAGEIF(A2:A10,">"&PERCENTILE(A2:A10,0.7))




回答3:


Without using VBA:

Putting data into column A.

Create this intermediate column B:

    B1=IF(RANK(A1,$A$1:$A$10)<=30*COUNT($A$1:$A$10)/(100), A1,0)
    B2=IF(RANK(A2, ...

Then Average this column with:

    =AVERAGEIF(B1:B10,">0")

For your given example you get 9.




回答4:


You could also do this without formulas by including a column title and choosing:

Data > Filter > Number Filter > Top 10...(Top 30 Percent)

Highlight the column to see sum, average, count, max. (Right-click the status bar and select "average" if not displayed.)

If you want the result of the filtered average in a cell you can use =SUBTOTAL(1,A2:A11)



来源:https://stackoverflow.com/questions/10852999/getting-average-of-top-30-of-the-values-in-one-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!