Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Highlighted
psublue98
New Contributor III

Issue with aggregating data in charts based on count distinct total condition

Hello - I have a survey question and response database where all user (UserID) responses (ChoiceID) to various questions (QuestionID) are logged. What we want to be able to do is identify all of the users choices made to all other questions based on when they log a particular choice to a certain question, ChoiceID 1199 that corresponds to QuestionID 399.

I'm using an expression within a table that generates the correct counts by row for a scenario where we're trying to identify the symptoms logged.

if(
count(distinct total <UserID> {<ChoiceID={'1199'}>} ChoiceID)>0,
count( {<ChoiceID={$(vSymptoms)}>} ChoiceID )
)

However, that same expression doesn't work in a chart as it's returning the total count of symptoms, not the counts based on when a UserID has logged a 1199 ChoiceID. It seems to have to do with UserID, but I can't figure it out. 

I've attached the app and dataset in excel to illustrate the desired results. For example, the correct total for symptom 1 = 574, not 640.

Thank you in advance and I'll buy you a free beer at Qonnections! Smiley Happy

1 Solution

Accepted Solutions
jwjackso
Valued Contributor

Re: Issue with aggregating data in charts based on count distinct total condition

How about:

=count( {<ChoiceID={$(vSymptoms)},UserID=P({<ChoiceID={'1199'}>}UserID)>} ChoiceID)

 

2 Replies
jwjackso
Valued Contributor

Re: Issue with aggregating data in charts based on count distinct total condition

How about:

=count( {<ChoiceID={$(vSymptoms)},UserID=P({<ChoiceID={'1199'}>}UserID)>} ChoiceID)

 

psublue98
New Contributor III

Re: Issue with aggregating data in charts based on count distinct total condition

Works beautifully, thank you!