CountIF depending on other fields? Survey problem

KapoJones

New Member
Joined
May 23, 2011
Messages
4
First, sorry if that has been asked before, I used the search function but didnt find what I'm looking for.

Hopefully one of you can solve my problem.

I did a survey that goes like this (I simplified things, these are not the real questions):


1. Are you happy?

[yes] [rather yes] [rather no] [no] [not gonna tell you] [I dont know]

2a) If question 1 yes or rather yes, because you ate apple?
2b) If question 1 no or rather no, was it because you didnt get apple?

[yes] [rather yes] [rather no] [no] [not gonna tell you] [I dont know]


So now I have my data collected in a data field, I was thinking its easiest to collect every data point by letters a-f (a = yes, b = rather yes, c= rather no...)

So the data looks like

Question1 Question2
Person1 a b
Person2 a c
Person3 d f
Person4 c a


For making graphs for the 1st question I did
COUNTIF(B:B,"a")
COUNTIF(B:B,"b")
COUNTIF(B:B,"c")

Thats easypeasy. But now I cant get my formula done for the second question depending on the first.

What I want is
Number of A when Question1 is A OR B
Number of B when Question1 is A OR B
Number of C when Question1 is A OR B


And
Number of A when Question1 is C OR D
Number of B when Question1 is C OR D
Number of C when Question1 is C OR D

I really tried hard, but I'm nowhere near a solution, so I'm seeking help here!
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
HTML:
{=SUMPRODUCT(IF(OR(B:B="A",B:B="B"),1,0),if(C:C="A",1,0))}

Do not type the { }, after typing the formula use CTRL+SHIFT+ENTER.

Extrapolate for your other examples.
 
Upvote 0
the formula looks good to me, but it doesnt work.

I only get, #VALUE! - I tried to look into it if its some small error, but couldnt get it working
 
Upvote 0
Restrict the range to only the values you are working with. C1:C100 for example, not C:C.
 
Upvote 0
with question 1 in column B and Question 2 in Column C, this should do the trick for you:

Number of A when Question1 is A or B
=COUNTIFS(C:C,"A",B:B,"A")+COUNTIFS(C:C,"A",B:B,"B")

Number of B when Question1 is A or B
=COUNTIFS(C:C,"B",B:B,"A")+COUNTIFS(C:C,"B",B:B,"B")

Number of C when Question1 is A or B
=COUNTIFS(C:C,"C",B:B,"A")+COUNTIFS(C:C,"C",B:B,"B")



Number of A when Question1 is C or D
=COUNTIFS(C:C,"A",B:B,"C")+COUNTIFS(C:C,"A",B:B,"D")

Number of B when Question1 is A or B
=COUNTIFS(C:C,"B",B:B,"C")+COUNTIFS(C:C,"B",B:B,"D")

Number of C when Question1 is A or B
=COUNTIFS(C:C,"C",B:B,"C")+COUNTIFS(C:C,"C",B:B,"D")
 
Upvote 0
That works!

Thanks so much both gehusi and blueridge227 for helping me.

I was already thinking of skipping conditional questions, but that saves me a bunch of place on my survey :-D
 
Last edited:
Upvote 0
HTML:
{=SUMPRODUCT(IF(B2:B11="a",1,0),IF(C2:C11="a",1,0))+SUMPRODUCT(IF(B2:B11="b",1,0),IF(C2:C11="a",1,0))}
 
Upvote 0

Forum statistics

Threads
1,224,595
Messages
6,179,798
Members
452,943
Latest member
Newbie4296

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