Multiple choice: track individual selected choices in piped text | XM Community
Question

Multiple choice: track individual selected choices in piped text

  • 23 April 2020
  • 3 replies
  • 210 views

I have looked at various options on how to deal with this challenge, but I cannot seem to find a solution.
Here goed the challenge, in a nutshell: for an experimental design, we first ask respondents to indicate, in a multiple choice question, which four (out of eight) options they would prefer. We then need to track the four selected options in four metadata fields (selected1, selected2, selected3, selected4), and the same for four non selected options (nonselected1, nonselected2, nonselected3, nonselected4), which we can then use in the experimental stimulus to systematically vary the number of (non)selected options that were approved.
Qualtrics piped text only allows me to obtain a single comma separated string of the selected options in the multiple choice question, but does not allow me to separate out the individual options that were selected into separate metadata fields. I have tried experimenting with the syntax (i.e. ${q://QID1/ChoiceGroup/SelectedChoices/1}, ${q://QID1/ChoiceGroup/SelectedChoices{1,1}}, ${q://QID1/ChoiceGroup/SelectedChoices//1} to try and reference individual items in the comma separated list, but to no avail.
Any help would be much appreciated.


3 replies

Userlevel 3
Badge +2

I will use JavaScript to separate out the values and store them into its own embedded data field.
Add JavaScript to any question after the question you collected the user's choice.
In the JavaScript, pull the ${q://QID1/ChoiceGroup/SelectedChoices} and store it in a javascript variable. Then use the .split() function:
String.prototype.split()to turn the string into an array.
Then loop through the array and store the individual choice into individual embedded data.
Qualtrics JavaScript Question API - Qualtrics Question APIThen you can use all the individual choice in the next question.

Many thanks! I managed to split out the selected choices, I'm still struggling a bit getting the non selected choices into embedded data, but I'll get there. Thanks a lot!!

Badge +1

https://www.qualtrics.com/community/discussion/comment/24568#Comment_24568Would you be able to go into a little more detail with how you split out the selected choices?

Leave a Reply