需要有关 Excel 中的中值 If 的帮助
我需要返回电子表格上某个类别的中位数。下面的例子
Airline 5
Auto 20
Auto 3
Bike 12
Airline 12
Airline 39
等。
如何编写一个公式来仅返回航空公司类别的中值。与 Average if 类似,仅适用于中位数。我无法重新排列这些值。谢谢你!
I need to return a median of only a certain category on a spread sheet. Example Below
Airline 5
Auto 20
Auto 3
Bike 12
Airline 12
Airline 39
ect.
How can I write a formula to only return a median value of the Airline Categories. Similar to Average if, only for median. I cannot re-arrange the values. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
假设您的类别位于单元格 A1:A6 中,相应的值位于 B1:B6 中,您可以尝试输入公式
=MEDIAN(IF($A$1:$A$6="Airline",$B$1:$ B$6,""))
在另一个单元格中,然后按CTRL+SHIFT+ENTER
。使用
CTRL+SHIFT+ENTER
告诉 Excel 将公式视为“数组公式”。在此示例中,这意味着IF
语句返回一个包含 6 个值的数组($A$1:$A$6
范围内的每个单元格之一),而不是单一值。然后,MEDIAN
函数返回这些值的中位数。请参阅 http://www.cpearson.com/excel/arrayformulas.aspx 了解类似信息使用AVERAGE
而不是MEDIAN
的示例。Assuming your categories are in cells A1:A6 and the corresponding values are in B1:B6, you might try typing the formula
=MEDIAN(IF($A$1:$A$6="Airline",$B$1:$B$6,""))
in another cell and then pressingCTRL+SHIFT+ENTER
.Using
CTRL+SHIFT+ENTER
tells Excel to treat the formula as an "array formula". In this example, that means that theIF
statement returns an array of 6 values (one of each of the cells in the range$A$1:$A$6
) instead of a single value. TheMEDIAN
function then returns the median of these values. See http://www.cpearson.com/excel/arrayformulas.aspx for a similar example usingAVERAGE
instead ofMEDIAN
.创建第三列,其值如下:
=IF(A1="Airline",B1)
=IF(A2="Airline",B2)
等等
然后只需对新列执行中值即可。
Make a third column that has values like:
=IF(A1="Airline",B1)
=IF(A2="Airline",B2)
etc
Then just perform a median on the new column.
扩展 Brian Camire 的答案:
使用
=MEDIAN(IF($A$1:$A$6="Airline",$B$1:$B$6,""))
和CTRL+SHIFT +ENTER
将在计算中包含空白单元格。空白单元格将被评估为 0,这会导致较低的中值。如果使用平均函数也是如此。如果您不想在计算中包含空白单元格,请使用嵌套的 if 语句,如下所示:不要忘记按
CTRL+SHIFT+ENTER
将公式视为“数组公式” 。Expanding on Brian Camire's Answer:
Using
=MEDIAN(IF($A$1:$A$6="Airline",$B$1:$B$6,""))
withCTRL+SHIFT+ENTER
will include blank cells in the calculation. Blank cells will be evaluated as 0 which results in a lower median value. The same is true if using the average funtion. If you don't want to include blank cells in the calculation, use a nested if statement like so:Don't forget to press
CTRL+SHIFT+ENTER
to treat the formula as an "array formula".一种解决方案可能是找到一种方法,从字符串中提取数字并将它们放入只有数字的列中,使用 =MEDIAN() 函数将新的数字列作为范围
one solution could be to find a way of pulling the numbers from the string and placing them in a column of just numbers the using the =MEDIAN() function giving the new number column as the range