Is there a way to display answers in alphabetical order for all translations? | XM Community
Skip to main content
Solved

Is there a way to display answers in alphabetical order for all translations?


The question Which country are you from? is alphabetized in English however when i look at the German or Dutch translations it looks a bit weird not starting with an A. Is there any way you can display the order of answers differently per language? Thank you

Best answer by TomG

You could duplicate the question, arrange the duplicate in German/Dutch alphabetical order, then use display logic to display the original question in English and the duplicate in German/Dutch. Your answers will be in two different questions in your data, so you could add a bit of survey flow logic to combine them in one embedded data variable. Another way to do it would be to use JavaScript to sort the list on the fly.
View original

10 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • Answer
  • November 28, 2018
You could duplicate the question, arrange the duplicate in German/Dutch alphabetical order, then use display logic to display the original question in English and the duplicate in German/Dutch. Your answers will be in two different questions in your data, so you could add a bit of survey flow logic to combine them in one embedded data variable. Another way to do it would be to use JavaScript to sort the list on the fly.

  • Author
  • 2 replies
  • November 28, 2018
Ok thanks , indeed duplicating would be less ideal. I'm not a Java expert though, is there a peace of code that i can copy in?

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • November 28, 2018
> @Ingrid said: > Ok thanks , indeed duplicating would be less ideal. I'm not a Java expert though, is there a peace of code that i can copy in? No, there isn't any code I'm aware of that you could copy. The JS would be fairly complex.

  • 1 reply
  • March 24, 2020
> @Ingrid said: > Ok thanks , indeed duplicating would be less ideal. I'm not a Java expert though, is there a peace of code that i can copy in? Did you happen to find a solution for this or develop JS? I'm working on a survey with over 10 translations so different versions of each would not be ideal at all.

Forum|alt.badge.img+1
  • 1 reply
  • August 4, 2020

https://www.qualtrics.com/community/discussion/comment/23399#Comment_23399JodieG hi, I'm also implementing a survey in 10 languages. Were you able to resolve this for the 10 translations?


  • 2 replies
  • January 4, 2021

https://www.qualtrics.com/community/discussion/comment/23399#Comment_23399The following JavaScript worked for me. It will grab the language currently selected in Qualtrics by the survey respondent and works with single choice, multiple answer, dropdowns, and select boxes.

/* Tweak to ensure dropdowns are sorted in other languages */
// Pull choices from current question
let targetElement = this.getChoiceContainer();
let myChoices = targetElement.children;
myChoices = Array.prototype.slice.call(myChoices);

// Sort choices
myChoices.sort(function(a, b) {
return a.textContent.localeCompare(b.textContent, '${e://Field/Q_Language}', {sensitivity: 'base', ignorePunctuation: true, numeric: true});
});

// Return choices to current question
for (let i=0; i < myChoices.length; i++) {
targetElement.appendChild(myChoices[i]);
}


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • January 4, 2021

https://www.qualtrics.com/community/discussion/comment/33043#Comment_33043It's fine if you only want to sort French.
Since the original post several months ago, I've written a JS function that provides a more robust solution (not free). It alphabetizes multiple choice questions (vertical single answer, vertical multi-answer, dropdown list, select box and multi-select box) on-the-fly based on the current language. It also supports anchored choices.
If anyone is interested, feel free to contact me by private message.


  • 2 replies
  • January 5, 2021

https://www.qualtrics.com/community/discussion/comment/33045#Comment_33045Hey Tom, good point. I make a tweak to the above so it works with the language currently selected in Qualtrics by the survey respondent.


Forum|alt.badge.img+1
  • Level 1 ●
  • 6 replies
  • March 12, 2024
Sam832 wrote:

https://www.qualtrics.com/community/discussion/comment/23399#Comment_23399The following JavaScript worked for me. It will grab the language currently selected in Qualtrics by the survey respondent and works with single choice, multiple answer, dropdowns, and select boxes.

/* Tweak to ensure dropdowns are sorted in other languages */
// Pull choices from current question
let targetElement = this.getChoiceContainer();
let myChoices = targetElement.children;
myChoices = Array.prototype.slice.call(myChoices);

// Sort choices
myChoices.sort(function(a, b) {
return a.textContent.localeCompare(b.textContent, '${e://Field/Q_Language}', {sensitivity: 'base', ignorePunctuation: true, numeric: true});
});

// Return choices to current question
for (let i=0; i < myChoices.length; i++) {
targetElement.appendChild(myChoices[i]);
}

wow, this worked amazingly well - thank you for sharing!

one question: is there a way to exclude answer options like ‘other’ or ‘none of these’ from the sorting? I appreciate any leads :)


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5926 replies
  • March 12, 2024

@EvaZw - The mcAlphabetize function supports anchored choices. It also works with all languages, which is not the case with the code above.


Leave a Reply