HOW TO

Reformat the results of Multiple Select Questions in Survey123

Last Published: February 10, 2025

Summary

Select Multiple Questions in Survey123 store the names of the selected choices as a CSV string, i.e., Option1,Option2,Option3,Option4. While it is useful to store the unique names of choices, sometimes we want to easily access a list of the labels of selected choices. For example, the plant names Acacia, Banksia, Callistemon, and Eucalyptus.

We have more flexibility and freedom with naming conventions when choosing Labels compared to Names. To improve readability, the CSV string also must be reformatted to include spaces between the options, which is time-consuming when done by hand. It is possible to create a new object in an XLSForm to reformat the selected choices using the Label instead of the Name. We can do this by combining a series of formulas in the Calculation field. The scientific and common names of some Australian plants are used in this example.

Procedure

  1. Create a Select Multiple question type, with an associated choice list. Make sure to note the number of choice options, this is neededfor the second part. We can also choose here to make the question required or not. In this case, we will not require an answer.

table1-au-plants-800px.png

  1. Create a Text question to store the reformatted labels. The appearance can be set to hidden if we don't want our survey takers to see the list. To populate this text question, we combine the selected-at(), jr:choice-name(), concat(), and if statement formulas.

table2-au-plants-800px.png

Creating the Calculation

As we will be combining multiple functions, it is a good idea to start at the endpoint and build outwards. To begin with we will use the jr:choice-name() and selected-at() functions:

  • The jr:choice-name() function for a given question returns the label associated with the name of the choice.
  • The selected-at() function must be used to extract the label for individual answers. 
  • The question must be defined inside quotes.
jr:choice-name(selected-at(${PlantSpeciesCSV},0), '${PlantSpeciesCSV}')

We can use the concat() function to join all the labels of all selected answers into one string, with our desired punctuation.

concat(jr:choice-name(selected-at(${PlantSpeciesCSV},0), '${PlantSpeciesCSV}'), ', ', jr:choice-name(selected-at(${PlantSpeciesCSV},1),  '${PlantSpeciesCSV}'), ', ', jr:choice-name(selected-at(${PlantSpeciesCSV},2), '${PlantSpeciesCSV}'), ', and ',  jr:choice-name(selected-at(${PlantSpeciesCSV},3), '${PlantSpeciesCSV}'))

From here we need to create a series of nested if statements to filter our labels by the number of answers chosen. We set the condition for each if statement to return true if we have a value or choice at the given number. Counting starts from zero, so '3' will return the fourth selected choice. For example, if we want to display the labels when we have selected three choices, we set the condition to selected-at(${PlantSpeciesCSV},2). If this condition returns TRUE, then our concatenated string is outputted, i.e.  Gold Dust Wattle, Silver Banksia, and Willow Bottlebrush. If the condition is false, then we test the next if statement. This continues until the condition returns TRUE. If none of the conditions are met, then we can specify that a custom statement such as, No Plants Observed is returned, indicating to us that no choices were selected.

if(selected-at($PlantSpeciesCSV},3),concat(jr:choice-name(selected-at(${PlantSpeciesCSV},0), '${PlantSpeciesCSV}'), ', ', 
jr:choice-name(selected-at(${PlantSpeciesCSV},1), '${PlantSpeciesCSV}'), ', ', jr:choice-name(selected-at(${PlantSpeciesCSV},2), '${PlantSpeciesCSV}'), ', and ', jr:choice-name(selected-at(${PlantSpeciesCSV},3),
'${PlantSpeciesCSV}')), if(selected-at($PlantSpeciesCSV},2),concat(jr:choice-name(selected-at(${PlantSpeciesCSV},0), '${PlantSpeciesCSV}'), ', ',
jr:choice-name(selected-at(${PlantSpeciesCSV},1), '${PlantSpeciesCSV}'), 'and ', jr:choice-name(selected-at
(${PlantSpeciesCSV},2), '${PlantSpeciesCSV}')), if(selected-at($PlantSpeciesCSV},1),concat(jr:choice-name(selected-at(${PlantSpeciesCSV},0), '${PlantSpeciesCSV}'), 'and ',
jr:choice-name(selected-at(${PlantSpeciesCSV},1), '${PlantSpeciesCSV}')), if(selected-at($PlantSpeciesCSV},0),jr:choice-name(selected-at(${PlantSpeciesCSV},0), '${PlantSpeciesCSV}'), 'No Plants Observed'))))

A couple of things to note:

  • Be aware of how many brackets you are opening. Issues can arise with unmatched pairs of brackets that can be difficult to locate. Especially if you have many choice options.
  • The IF statements need to start with the instance where the greatest number of selections are made and cascade downward to only one. If not, the first IF statement will return true, and the output string will only contain the Label for the first selection even if multiple selections were made.

Article ID: 000031066

Software:
  • ArcGIS Survey123 Connect
  • ArcGIS Survey123 Website

Receive notifications and find solutions for new or common issues

Get summarized answers and video solutions from our new AI chatbot.

Download the Esri Support App

Discover more on this topic

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options