Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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
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
Thank you very much for your fast answer, Marcus! That worked!