How to carryforward the first ranked choice in a group in a Pick, Group and Rank question. | XM Community
Skip to main content

Dear Qualtrics Community,
I am doing a Survey where I ask people to pick their top 3 preferred majors. To make sure they don't get mistaken, I created 3 groups that correspond to First Choice, Second Choice and Third Choice. So they would have to drag from the list of majors just one option per box ( I attach a picture). I wanted to be able to retrieve their First Choice later in the survey, something similar to what ${q://QIDX/ChoiceGroup/ChoiceWithLowestValue} is for the rank question.
Does anyone has an idea of how I could do it?
Thanks a lot!
Screenshot 2022-05-16 at 19.40.12.png

I just found a workaround to make it work!
For anyone who is interested, I extracted a portion of the piped text that is storing the 3 selected choices, precisely, I extract the digits before the comma. Here below the code:
Please note that this code has to be placed after the Pick, Group and Rank question and you can star displaying the substring from the question after the one where you put the code.

Qualtrics.SurveyEngine.addOnload(function()
{
var str = "${q://QID26/ChoiceGroup/SelectedChoices}";
var FirstChoice = str.substring(0,str.indexOf(","));
Qualtrics.SurveyEngine.setEmbeddedData("FirstChoice", FirstChoice);
});

Qualtrics.SurveyEngine.addOnReady(function()
{

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/


});


Leave a Reply