I am pretty sure that I saw this problem solved somewhere already but I cannot find it.
Assuming that I have a multiple_select answer that has the selected answers concatenated by a comma:
Banana, Apple, Orange, Strawberry, Tree_Tomato
Now I would like to save these answers to different columns (=questions) in my survey
First Answer: Banana
Second Answer: Apple
Third Answer: Orange
Fifth Answer: Tree_Tomato
How can I extract the answers separately depending on their position?
Solved! Go to Solution.
Hi Nicole
This can be achieved using the selected-at() function, which will return the name for the choice at the given position. Note that this is indexed from zero. For example, to return the name of the third selected choice:
selected-at(${fruit},2)
This function is described here: https://community.esri.com/groups/survey123/blog/2018/12/02/survey123-tricks-of-the-trade-xlsform-fu...
And also documented here Formulas—Survey123 for ArcGIS | Documentation and here XLSForm essentials—Survey123 for ArcGIS | Documentation.
Cheers,
Jim
Hi Nicole
This can be achieved using the selected-at() function, which will return the name for the choice at the given position. Note that this is indexed from zero. For example, to return the name of the third selected choice:
selected-at(${fruit},2)
This function is described here: https://community.esri.com/groups/survey123/blog/2018/12/02/survey123-tricks-of-the-trade-xlsform-fu...
And also documented here Formulas—Survey123 for ArcGIS | Documentation and here XLSForm essentials—Survey123 for ArcGIS | Documentation.
Cheers,
Jim
Thanks a lot, I should have looked into the documentation first...
Any hint how I could split up a text when several answers are give in a free text question? When I give the option to list "others" and the user fills "Avocado, Cucumber, Tomato, Corn", is there a way to save those also separated in additional columns/questions? I found a lot in excel for only three values (like left, mid, right) but couldn't figure out how to do it with more than three items in the list.
Hi Nicole
As mentioned in this post, there isn't a function for this in XLSForm. A JavaScript function (currently in beta) could help (refer to EAC).
For a calculation to work, users would have to type their list of additional entries in a strict format, which could be difficult to enforce. If your aim is to write each entry to a separate question anyway, one suggestion is to have one question per additional input; you could use something like string-length({$previous})>0 in the relevant column to hide the next question until it's needed. This would avoid issues with inconsistent data entry into a single text question.
One consideration with this approach is you would need to have a capped number of additional entries (questions).
Hope this helps!
Cheers,
Jim
Thanks a lot Jim!