Reputation: 97
I have an excel sheet that looks like this (with many more columns and rows of course):
condition a | condition b | condition c | condition d | result (a,b) | result (c,d) |
---|---|---|---|---|---|
yes | no | yes | no | 0 | 1 |
no | no | no | yes | 0 | 1 |
yes | yes | no | no | 1 | 0 |
...
Now, I only want to separately count the occurrences of either a or b or both are occurring per row, but want to exclude all instances where either a or b (or both) are occurring together with c or d, since I want to count the occurrences where either c or d or both are apperearing separetely. I have toyed around with the idea of using the countifs
, but my problem is that I want to count every row separately, so if a and b occur together I only want to count them once, so if I applied countifs
to all the colums together, it would count all instances of yes in the a and b column.
For example here in the first row, I would get a 1 for c,d and a 0 for a,b since while there is a yes for a in the first row, there is also one for c. In the second row, we only have yes for d so it's easy that it's easyily 1 for c,d and 0 for a,b.
And finally in the third row we only have a,b both yes, so it's 1 for a,b since I want to know the occurence per row, and since there is no for both c and d, and so it's 0 for c,d since both are no.
Does anyone know how to solve this in excel? Thank you all for your help
Upvotes: 0
Views: 70
Reputation: 152650
Use AND and OR (COLUMN E):
=--AND(AND(C2<>"yes",D2<>"yes"),OR(A2="yes",B2="yes"))
And (COLUMN F)
=--OR(D2="yes",C2="yes")
If you want to count without the helper columns:
A,B:
=SUMPRODUCT(((C2:C4<>"yes")*(D2:D4<>"yes"))*((A2:A4="yes")+(B2:B4="yes")>0))
C,D:
=SUMPRODUCT(--((C2:C4="yes")+(D2:D4="Yes")>0))
Upvotes: 2