• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Sumproduct to addup only the rows which addup to a positive value

prakasharadhana

New Member
Using sumproduct to arrive at sum of rows of an array which satisfy the below:
1. the column condition
2. the row condition
3. the sum of the row should be a positive value
Thank you.

Excel sheet attached, snapshot below:
74524
 

Attachments

  • sumproduct.xlsx
    11.4 KB · Views: 7
Based on your formula, just add a condition checking for non-negative value rows,

so,

In E17, enter formula :

=SUMPRODUCT(C4:G9,(C3:G3<=E12)*(B4:B9=F12)*(COUNTIF(OFFSET(C3:G3,ROW(C4:G9)-ROW(C3),0),">=0")=5))

74527
 
Last edited:
@bosco_yip
I want the formula to be dynamic, the above is just test data, I want to apply it to much larger data.

Also if you could explain what the last part of the formula does, it would make it easier for me. Thanks in advance.
 
@bosco_yip
So what I found the problem now is the above formula ignores any row that has a negative value, but what I want is to ignore the row only if the sum of the values is negative. I hope you get it.
 
Please try

=SUM(--TEXT(MMULT((C3:G3<=E12)*(B4:B9=F12)*C4:G9,TRANSPOSE(C3:G3)^0),"0;\0"))
with Ctrl+Shift+Enter

or
=SUMPRODUCT(--TEXT(MMULT((C3:G3<=E12)*(B4:B9=F12)*C4:G9,ROW(A1:INDEX(A1:A20,COLUMNS(C3:G3)))^0),"0;\0"))
normal Enter
 

Attachments

  • sumproduct - Copy.xlsx
    192 KB · Views: 4
Please try

=SUM(--TEXT(MMULT((C3:G3<=E12)*(B4:B9=F12)*C4:G9,TRANSPOSE(C3:G3)^0),"0;\0"))
with Ctrl+Shift+Enter

or
=SUMPRODUCT(--TEXT(MMULT((C3:G3<=E12)*(B4:B9=F12)*C4:G9,ROW(A1:INDEX(A1:A20,COLUMNS(C3:G3)))^0),"0;\0"))
normal Enter

Hi, I could not understand the cell reference A1:A20 in the sumproduct formula above.
 
Back
Top