I would like to multiply two cells in a same row, if a condition of a third adjacent cell is met; then sum the result to the next product in the next row (if condition is met), and so on.
| A | B | C |
---|---|---|---|
1 | | | |
2 | | | |
3 | | | |
4 | | | |
Something like this:
Loop (from i = 1 to i = 4)
if (Ci == "Some text")
sum += (Ai * Bi)
I have tried with this formula, which doesn't work:
=SUMPRODUCT(A1:A4, B1:B4, IF(C1:C4="Some text", 1, 0))
And this, which gives me some incorrect sum. EDIT: It does work, I was blind.
=SUMPRODUCT(A1:A4, B1:B4, C1:C4="Some text")
What am I doing wrong, and how should I proceed?
EDIT: Now I see that the conditional =IF(test, then_value, otherwise_value) doesn't seam to accept a range for the test value.
So, how can this be archived?
EDIT 2: I was blind. Indeed, this works:
=SUMPRODUCT(A1:A4, B1:B4, C1:C4="Some text")