Reputation: 5
I want to SUM multiple columns but only for rows whose SUM is >0. One approach that works is to add an extra column that in essence excludes rows whose SUM is <0 and then sum that extra column as in the screenshot below. My desire is to eliminate the helper column and create a single formula based only on the original data that returns the same result. I've tried to include FILTER() inside a SUMIF() and a few other possibilities but to no avail.
Note: I am on O365 with dynamic array support if that helps. Thanks in advance.
Upvotes: 0
Views: 1320
Reputation: 3802
In G2
, enter formula :
=SUMPRODUCT((MMULT(A2:C4,{1;1;1})>0)*MMULT(A2:C4,{1;1;1}))
Upvotes: 1
Reputation: 1471
If I understand what you mean, using the MMult function will help convert the matrix A2:C4
to E2:E4
as you say.
-You can use the LET function, if you have Office365-Insider,
=LET(x,A2:C4,y,MMULT(x*1,SEQUENCE(COLUMNS(x))^0),SUM(y*(y>0)))
-Or missing LET:
=SUM(MMULT(A2:C4*1,SEQUENCE(COLUMNS(A2:C4))^0)*(MMULT(A2:C4*1,SEQUENCE(COLUMNS(A2:C4))^0)>0))
The reason I use x*1 is to avoid possible errors if you leave a cell blank.
Upvotes: 2