Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Do a count on specific values

Hi,
I got a large number of different questionnaires that I'm analysing using QLikView.
A quiestionniare is having:
- a name
- 1-m "Categories" (headers)
- each Category got 1-m questions.

When a questionnaire is selected (filtered) I would like to count how many have answered "Yes" to the question "Do you agree?" - whitout that specific question is filtered, meaning only filter is Questionnare Name. I got other answer combinations that needs to be counted as well (logic will be the same as above). All those values will be plotted in a line chart.

It might help you understand if you see my failed attemp: count(Aggr(PQQ_QUESTION_TEXT = 'Do you agree?' AND ANS_ANSWERALTERNATIVE = 'Yes', ANS_ANSWER_ID))

Hope that one of you guru's can point me in the right direction?

Regards
Nikolaj

1 Solution

Accepted Solutions
martin59
Specialist II
Specialist II

Hi Nikolaj,

I don't understand why the Juerg's expression does not work. Are you sure about your field names and values.

You can also try this expression :

count({<PQQ_QUESTION_TEXT = {'Do you agree?'}, ANS_ANSWERALTERNATIVE = {Yes}>} ANS_ANSWER_ID)

Martin

View solution in original post

7 Replies
Not applicable
Author

Hi Nikolaj

does this show your expected result?


sum(if(PQQ_QUESTION_TEXT = 'Do you agree?' AND ANS_ANSWERALTERNATIVE = 'Yes', 1))


Juerg

Not applicable
Author

Hi Juerg,

Unfortinately your expression does not work.

Thanks for trying anyway 🙂

/Nikolaj

martin59
Specialist II
Specialist II

Hi Nikolaj,

I don't understand why the Juerg's expression does not work. Are you sure about your field names and values.

You can also try this expression :

count({<PQQ_QUESTION_TEXT = {'Do you agree?'}, ANS_ANSWERALTERNATIVE = {Yes}>} ANS_ANSWER_ID)

Martin

Not applicable
Author

Hi Martin,

Juerg's expression is returning a different number than expected. Why I don't know. Yours on the other hand gives me the values I'm looking for!

Thanks for the effort both of you 🙂

Regards

Nik

Not applicable
Author

Hi,

I ran into another problem similar to the one described here.

I need to do a calculation where I have to count how many people (answerID) have answered a specific combination to 2 questions. Martin's expression works fine for one question but I need to have it "nested" with another question/answer.

So the expressions seperated looks like this:

count({<PQQ_QUESTION_TEXT = {'Do you agree?'}, ANS_ANSWERALTERNATIVE = {Yes}>} ANS_ANSWER_ID)

count({<PQQ_QUESTION_TEXT = {Did you have any problems?'}, ANS_ANSWERALTERNATIVE = {Yes, serious problems}>} ANS_ANSWER_ID)

But how to I combine the to give me a count of answerID's that have answered "Yes" to the first question AND "Yes, serious problems" to the other question?

Regards

Nik

P.s. Let me know if I should open another thread since it's a new question?

martin59
Specialist II
Specialist II

Hello,

If you want to count of answerID's that have answered "Yes, serious problems" to the second question, do this :

count({<PQQ_QUESTION_TEXT = {'Did you have any problems?'}, ANS_ANSWERALTERNATIVE = {'Yes, serious problems'}>} ANS_ANSWER_ID)


If you want to intersect the 'Yes' on the first question and 'Yes, serious problems' on the second, try this :

count({<PQQ_QUESTION_TEXT = {'Do you agree?'}, ANS_ANSWERALTERNATIVE = {Yes}>*<PQQ_QUESTION_TEXT = {'Did you have any problems?'}, ANS_ANSWERALTERNATIVE = {'Yes, serious problems'}>} ANS_ANSWER_ID)


Hope it works and helps you.

Martin

Not applicable
Author

Thanks 🙂