Hello,
I'm creating a survey in Survey123 Connect which contains a select multiple question type. I'm using numeric codes for the choice names and standard text labels for the front end selection. I'd like to have these labels returned within a hidden text field so I can then view the labels instead of the codes for future use in dashboards or other apps. I'm using this calculation expression
jr:choice-name(selected-at(${layerlist}, 1), '${layerlist}')
found via this post - https://community.esri.com/t5/arcgis-survey123-questions/select-multiple-list-no-save-label/td-p/113...
I noticed that there is a choice index number within the expressions which specifies which selection to return. I would like to return all of the select multiple selections and not just a single choice. Is it possible to return all of the choices? If so what would I input in the choice index section of the expression? Any help is appreciated.
Thanks,
I never found a way but would love to hear if there is one. I had to list out the total possible options. So if you have a list with 6 options then you write out jr:choice-name(selected-at(${layerlist}, 1), '${layerlist}') from 0 to 5. If there are only 3 then nothing is returned for 4, 5, 6 so it worked out ok using spaces but it could lead to extra spaces or commas. Not awesome but the best I could come up with.
I agree with @DougBrowning that you have to list all the choices out. To combat the issue of extra commas and spaces, I chain multiple if statements together based on the number of selected choices.
I add a hidden integer question that counts the number of selected choices: count-selected(${ind_roles})
Then use that to build out the if statements. (If 3 choices are selected.... if 2 choices are selected..... etc).
if(${ind_roles_ct} = 3, concat(jr:choice-name(selected-at(${ind_roles}, 0), '${ind_roles}'), ', ', jr:choice-name(selected-at(${ind_roles}, 1), '${ind_roles}'), ', ', jr:choice-name(selected-at(${ind_roles},2), '${ind_roles}')),
if(${ind_roles_ct} = 2, concat(jr:choice-name(selected-at(${ind_roles}, 0), '${ind_roles}'), ', ', jr:choice-name(selected-at(${ind_roles}, 1), '${ind_roles}')),if(${ind_roles_ct} = 1, jr:choice-name(selected-at(${ind_roles}, 0), '${ind_roles}'), '')))