Hello I need to make a sumproduct
with general conditions. The correct values is shown in cell B6
, B7
and B8
In cell B6
I have this formula =A1*A2+B1*B2+C1*C2
to understand what is the result that I expected.
In B7
is =D1*D2+E1*E2
and so on...
I've tried with this formula =SUMPRODUCT(A3:G3=A6,A1:G1,A2:G2)
in cell B6
but the result is 0.
Use =SUMPRODUCT(1*(A3:G3=A6),A1:G1,A2:G2)
in cell B6
.
Better still use =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.
From this page , I learned that "--" can transform True and False values into 1's and 0's.
That's probably why you are getting 0, the formula you use adds boolean values to numerical values.
So the formula you are looking for in cell B6 is =SUMPRODUCT(--(A3:G3=A6),A1:G1,A2:G2)
.
Tested on Excel 2010, it worked.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.