表:
Name Price New/Old
A 10 Y
A 20 N
B 35 Y
B 45 Y
C 50 N
C 60 Y
如果我想找到:name = A和New / Old = Y的平均价格:
IFERROR(AVERAGEIFS($B$2:$B$7, $A$2:$A$7, "A", $C$2:$C$7, "Y"),"") = 10
这相关容易。
然而,当名字= A或B以及新/旧= Y时找到平均价格时我陷入困境。
正确的答案应该是:(10 + 35 + 45)/ 3 = 30
提前致谢!
答案 0 :(得分:2)
使用数组的更直接的方法:
=AVERAGE(IF((($A$2:$A$7="A")+($A$2:$A$7="B")+($C$2:$C$7="Y"))=2,$B$2:$B$7))
请记住输入数组公式hold Shift
+ Ctrl
并点击Enter
答案 1 :(得分:1)
可能有一种更容易/更有说服力的方式,但是应该这样做:
=(SUMIFS($B$2:$B$7, $A$2:$A$7, "A", $C$2:$C$7, "Y")+SUMIFS($B$2:$B$7, $A$2:$A$7,
"B", $C$2:$C$7, "Y"))/(COUNTIFS($A$2:$A$7, "A", $C$2:$C$7, "Y")+
COUNTIFS($A$2:$A$7, "B", $C$2:$C$7, "Y"))
答案 2 :(得分:1)
非数组公式
=SUM(SUMIFS(B2:B7,A2:A7,TRANSPOSE({"A","B"}),C2:C7,"Y"))/
SUM(COUNTIFS(A2:A7,TRANSPOSE({"A","B"}),C2:C7,"Y"))
虽然,但是西蒙更整洁
编辑:在Barry的评论之后
=SUM(SUMIFS(B2:B7,A2:A7,{"A","B"},C2:C7,"Y"))/SUM(COUNTIFS(A2:A7,{"A","B"},C2:C7,"Y"))