Calculating average of specific values

白昼怎懂夜的黑 提交于 2019-12-11 15:39:26

问题


I want to find out the average cost of an apple, the price isn't always filled out, I know I should be able to do this with sumproduct, but it's not working for me.

  A       B
Fruit   Price
Apple   56
Banana  23
Apple   
Apple   40
Apple   

My problem comes when I try to count how many apples have a price value entered. Can anyone help?

Note: I'm using Excel 2003 hence no countifs


回答1:


So you expect to get 48 as the average for Apple?

Two possible ways.....

An array formula with AVERAGE

=AVERAGE(IF(A2:A10="Apple",IF(B2:B10<>"",B2:B10)))

confirmed with CTRL+SHIFT+ENTER

....or use SUMIF/SUMPRODUCT

=SUMIF(A2:A10,"Apple",B2:B10)/SUMPRODUCT((A2:A10="Apple")*(B2:B10<>""))



来源:https://stackoverflow.com/questions/19299160/calculating-average-of-specific-values

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