Countif with matrix

Rubsie

New Member
Joined
Feb 16, 2009
Messages
7
Hi,

I have the following table and I would like to count the amount of rows in which either column x, y OR z has a value greater than 0. I'm assuming this has to be done with an array formule as I do not want to create a helper column.
In the example below, the result of this calculation is 5 (rows A, C, D, F and G have a value in one of the 3 columns greater than 0).
xyz
A010
B000
C111
D001
E000
F110
G011

<tbody>
</tbody>

Does anyone know how to do this?
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi,

I imagine there's a non-array solution as well, but this array formula** should work:

=SUM(0+(MMULT(0+(A1:C7>0),TRANSPOSE(COLUMN(A1:C7))^0)>0))


Regards


**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).</SPAN></SPAN>
 
Upvote 0
Hi, a non-array solution (although not the simplest I fear) :

=SUMPRODUCT(NOT(B2:B8)*NOT(C2:C8)*NOT(D2:D8)*NOT(E2:E8)*NOT(F2:F8)*NOT(G2:G8)*NOT(H2:H8))
 
Upvote 0
Hi XOR LX,

Thank you, works great. Now, if I'd like to check whether values in row x > 0, row y > 1 and row z > 2, MMULT can no longer be used? What solution could be used in that case? (I used values of 0 and 1 for ease of explanation but now I realise it makes the solution for my problem different). :s

Thank you.
 
Upvote 0
...Now, if I'd like to check whether values in row x > 0, row y > 1 and row z > 2, MMULT can no longer be used? What solution could be used in that case? (I used values of 0 and 1 for ease of explanation but now I realise it makes the solution for my problem different)...

An exhibit for clarification along with the desired result would be helpful. Guessing from he short specs:

=SUM(IF(FREQUENCY(IF((B2:B8>0),IF(C2:C8>1,IF(D2:D8>2,ROW(A2:A8)))),ROW(A2:A8)),1))

which must be confirmed with control+shift+enter.
 
Upvote 0
Just change to:

=SUM(0+(MMULT(0+(A1:C7>{0,1,2}),TRANSPOSE(COLUMN(A1:C7))^0)>2))


Regards
 
Upvote 0
Try this:

Code:
Use Ctrl+Shift+Enter to enter the formula

=COUNT(1/MMULT(-($B$2:$D$8>{0,1,2}),TRANSPOSE(COLUMN($B$2:$D$2))))

Markmzz
 
Upvote 0
@markmzz

This doesn't work. It will include any row containing non-zero values e.g. {1,1,1}, whether they meet the criteria of >0, >1, >2 respectively or not.

Regards
 
Upvote 0

Forum statistics

Threads
1,214,583
Messages
6,120,383
Members
448,956
Latest member
JPav

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top