简体   繁体   English

Excel公式(如果,sumproduct…)

[英]Excel Formula (if, sumproduct…)

I have this table in Excel where you can see the kg and the Price which I buy a product. 我在Excel中有此表,您可以在其中查看购买产品的千克和价格。

在此处输入图片说明

And I want to obtain the mean Price and the mean kg that I buy for each day of the week of January. 我想获得一月份一周中每一天的平均价格和平均公斤数。 For the Kg: 对于公斤:

=AVERAGEIF($B$4:$B$11;"Friday";D$4:D$11)

But I don't know how to do this for the mean of the Price because I have to consider the kg that I have bought. 但是我不知道如何按照价格的平均值进行操作,因为我必须考虑购买的公斤数。 I have tried with SumProduct, If, or Sumif , but I can't do it. 我已经尝试过SumProduct,If或Sumif ,但是我做不到。

I know how to do it if I add a new column that makes C*D but I prefer do it without it. 如果我添加一个使C * D成为新的列,我知道该怎么做,但是我更喜欢没有它的情况。

Try this: 尝试这个:

=SUM(IF(B4:B14="Friday",C4:C14*D4:D14))/SUM(IF(B4:B14="Friday",D4:D14))

IMPORTANT: this is an array formula and must be confirmed with Ctrl + Shift + Enter . 重要提示:这是一个数组公式,必须使用Ctrl + Shift + Enter进行确认。

这应该工作:

=SUMPRODUCT(C4:C11,D4:D11*(B4:B11="Friday")) / CountIf(B4:B11,"Friday")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM