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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Separating custom variable input

Dear community,

I have a custom variable "questionnaire" which tracks the following user's examplary inputs:

"Yes (explanation XYZIAHDFHFJ) | Yes (explanation JWKFN)| No (explanation ADKFJ)". The user can answer with Yes or No and has to provide some explanation, which is then in my variable directly attached to their answer.

I would now like to count all those users who never answered with no - or in other words: who always have a yes.

The problem: the explanation part written in brackets can range from one character to many characters, dependig on the users' input. This makes it so difficult to separate the multiple Yes. "left(questionnare,2) = 'Yes'" does not work, as I never know how long the explanation part is going to be.

Any suggestions on how to solve this?


Thank you very much in advance for your help!!

Best

1 Solution

Accepted Solutions
marcus_sommer
MVP
MVP

If your data-source looks like in your example you could split the various answers in separate columns, for example with something like:

load

     recno() as RecNo, iterno() as IterNo,

     trim(subfield(subfield(questionnaire, '|', iterno()), '(', 1)) as Answer,

     textbetween(subfield(questionnaire, '|', iterno()), '(', ')')) as Explanation

from Source while iterno() <= substringcount(questionnaire, '|') + 1;

After that you could just make a count over your Answer column.

- Marcus

View solution in original post

2 Replies
marcus_sommer
MVP
MVP

If your data-source looks like in your example you could split the various answers in separate columns, for example with something like:

load

     recno() as RecNo, iterno() as IterNo,

     trim(subfield(subfield(questionnaire, '|', iterno()), '(', 1)) as Answer,

     textbetween(subfield(questionnaire, '|', iterno()), '(', ')')) as Explanation

from Source while iterno() <= substringcount(questionnaire, '|') + 1;

After that you could just make a count over your Answer column.

- Marcus

Anonymous
Not applicable
Author

Thank you very much for your fast answer, Marcus! That worked!