[英]Excel SUMPRODUCT and MMULT with condition
Hello I need to make a sumproduct
with general conditions. 您好,我需要在一般条件下
sumproduct
。 The correct values is shown in cell B6
, B7
and B8
正确的值显示在单元格
B6
, B7
和B8
In cell B6
I have this formula =A1*A2+B1*B2+C1*C2
to understand what is the result that I expected. 在单元格
B6
我有这个公式=A1*A2+B1*B2+C1*C2
以了解我期望的结果是什么。
In B7
is =D1*D2+E1*E2
and so on... 在
B7
是=D1*D2+E1*E2
,依此类推...
I've tried with this formula =SUMPRODUCT(A3:G3=A6,A1:G1,A2:G2)
in cell B6
but the result is 0. 我尝试在单元格
B6
使用此公式=SUMPRODUCT(A3:G3=A6,A1:G1,A2:G2)
,但结果为0。
Use =SUMPRODUCT(1*(A3:G3=A6),A1:G1,A2:G2)
in cell B6
. 在单元格
B6
使用=SUMPRODUCT(1*(A3:G3=A6),A1:G1,A2:G2)
Better still use =SUMPRODUCT(1*(A$3:G$3=A6),A$1:G$1,A$2:G$2)
最好还是使用
=SUMPRODUCT(1*(A$3:G$3=A6),A$1:G$1,A$2:G$2)
and you will be able to copy the formula from B6
to B7:B8
and it will behave as you want. 然后您就可以将公式从
B6
复制到B7:B8
,它将按您的意愿运行。
From this page , I learned that "--" can transform True and False values into 1's and 0's. 通过此页面 ,我了解到“-”可以将True和False值转换为1和0。
That's probably why you are getting 0, the formula you use adds boolean values to numerical values. 这可能就是为什么您得到0,所使用的公式将布尔值添加到数值中的原因。
So the formula you are looking for in cell B6 is =SUMPRODUCT(--(A3:G3=A6),A1:G1,A2:G2)
. 因此,您在单元格B6中寻找的公式是
=SUMPRODUCT(--(A3:G3=A6),A1:G1,A2:G2)
。
Tested on Excel 2010, it worked. 在Excel 2010上进行了测试,它可以正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.