Excel:平均如果
假设我有一个 Excel 工作表,其中:
第 1 列包含工资
第 2 栏包含性别(男/女)
我如何计算女性的平均工资?
Lets say I have an Excel sheet such that:
Column 1 contains salaries
Column 2 contains gender (M/F)
How can I calculate the average salary for females?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
作为数组函数输入(即使用 Shift-CTRL-Enter 而不仅仅是 Enter)
entered as an array function (ie using Shift-CTRL-Enter rather than just Enter)
尽管答案已经被回答/接受,但我还是忍不住添加我的 2 美分:
总和和平均值通常显示在列表的底部。您可以使用 SUBTOTAL() 函数计算总和和平均值,并指定包括或排除“隐藏”值,即由过滤器抑制的值。因此,解决方案可能是:
=SUBTOTAL(101,A2:A6)
=SUBTOTAL(109,A2:A6)
现在,当您筛选“F”、“M”或全部时,将始终计算正确的总和和平均值。
希望有帮助 - 祝你好运
Allthough the answer is already answered/accepted I can't resist to add my 2 cents:
Sums and averages normally are displayed at the bottom of a list. You can use the SUBTOTAL() function to calculate sum and average and specify to include or exclude "hidden" values, i.e. values suppressed by a filter. So the solution could be:
=SUBTOTAL(101,A2:A6)
for the average=SUBTOTAL(109,A2:A6)
for the sumNow, when you filter for "F", "M" or all, the correct sum and average will always be computed.
Hope that helps - Good luck
要在没有数组公式的情况下执行此操作,只需使用以下命令:
To do it without an array formula just use this:
已回答的问题,可靠的公式 - 但是 - 请注意基于数字的条件平均值:
在非常相似的情况下,我尝试过:
“=AVERAGE(IF(F696:F824<0;E696:E824))”(移位控制输入) - 在英语中,如果 F 列中的结果为负(损失),则要求 Excel 计算 E 列中所有数字的平均值 - 例如“计算发生损失的所有项目的平均值”。 (无循环引用)
当要求计算发生增益 (x>0) 的所有项目的平均值时,Excel 是正确的。然而,当条件平均值基于损失时,Excel 产生了巨大的错误(7.53 而不是 28.27)。
然后,我在 Open Office 中打开完全相同同一个文档,Calc 从同一个数组公式中得到了(正确)答案 28,27。
在 Excel 中分步骤重新计算整个过程(第一个新列仅包含损失,新列仅包含增益,新列仅包含发生损失/增益的 E 值,然后进行“干净”(无条件)平均计算,生成正确的值 因此,
应该注意的是,在某些条件平均值的情况下,Excel 和 Open Office 会产生不同的答案(Excel 2007(瑞典语版本)会出错)
(抱歉,我的警告性故事很长,但在计算结果时要小心一点) 。条件是一个数字是我的建议)
Answered question, solid formulas - BUT - beware of conditional averages based on numbers:
In a very similar situation I tried:
"=AVERAGE(IF(F696:F824<0;E696:E824))" (shift control enter) - In English this asked Excel to calculate an average on all numbers in column E if a result in column F was negative (a loss) - e.g. "calculate an average for all items where a loss occured". (no circular reference)
When asked to calculate an average for all items where a gain (x>0) occured, Excel got it right. However, when the conditional average was based on a loss - Excel produced a huge error (7.53 instead of 28.27).
I then opened exactly the same document in Open Office, where Calc got the (correct) answer 28,27 from the same Array formula.
Recalculating the whole thing in steps in Excel (first new column of only losses, new for only gains, new column for only E-values where a loss/gain occured, then a "clean" (unconditional) average calculation, produced the correct values.
Thus, it should be noted that Excel and Open Office produce different answers (and Excel 2007, Swedish language version, gets them wrong) in some cases of conditional averages.
(sorry for my long cautionary tale - but be a bit careful when the condition is a number would be my advice)
您可以将过滤器放在工作表的顶行。然后从 Column2 中仅过滤
F
,然后计算值的平均值。You can put filter in top line of your sheet. Then Filter only
F
s from Column2, then calculate average of values.或者您可以添加仅包含女性工资的附加列。
公式如下: =IF(B1 = "Female";A1)
然后您只需计算新创建列的平均值。
Or you can add additional column with female salaries only.
The formula would be like: =IF(B1 = "Female";A1)
Then you simply calculate average of newly created column.
薪资性别
2500米0 2500*0
2400 F 1 2400×1
2300 F 1 2300×1
sum =2 sum=4700average=4700/2
也许很复杂。
Salaries gender
2500 M 0 2500*0
2400 F 1 2400×1
2300 F 1 2300×1
sum =2 sum=4700 average=4700/2
Maybe it be complex.