How do you get survey solutions to return the label associated with a selection made in a Categorical: Single Select question?
mainWater is a Categorical: Single Select
I want to create a variable that returns a string -
selectedWater type string
mainWater == 10 ?
mainWater == 20 ?
mainWater == 30 ?
Is there an easier way to do this? Is there a method something like this -
no there is no such method because potentially this will create different behavior when you switch the language of the questionnaire, e.g. from English to French.
If you want to display a value, just use %selectedWater% (that’s percent-selectedWater-percent).
If the codes are 0,1,2,3,4… you can do
with understanding that you will need to maintain two sets of labels in parallel, and that the language setting will not affect your syntax. Notice indexing starts with ZERO.
Perhaps, if you describe what you intend to do, we can come to a better solution.
Best regards, Sergiy Radyakin
I am glad this solved the issue. Thank you for confirming!
I used your recommendation (String) and works as expected.
Sorry for all the questions.
All the best,
I’m struggling with a similar issue here. My problem is the following:
I have a single-select question (combo style) with the name of the household head (lets call it hh_name). Since the survey will be by phone, we will ask the respondent to confirm he is the household head %hh_name%. Let say this question is called hh_confirmation and this is also a single select (1=yes, 2=no). In case the answer is no, then we will ask the respondent its name (string question, resp_name).
Now, I would like to create a variable with the name of the respondent, be it the household head or not (v_name).
But I can’t find a way to access the label of the question hh_name rather than the code.
The expression of my v_name of type string should look like this:
hh_confirmation ==1 ?
//expression to get the string value associated with hh_name
//hh_name, %hh_name% , hh_name.String() do not work
// what could I do?
Any hint would be very appreciated, since I have face this issue under different circumstances.
@pascaltillie , the linked question contains not the names, but the codes of the persons, as per:
So in order to obtain the actual name you need to dereference it using the original source of the items for the linked question.