Counting responses from multiple questions | XM Community
Skip to main content
Solved

Counting responses from multiple questions


mkosterich
I have a ranking question that I only want to display if a participant selects a specific dropdown item 2 or more times in the previous matrix questions. Since there are multiple questions, I can't use the display logic to count. ! If they select "Extremely Painful" two or more times, then display the question. Is there a way to tally up the count from multiple questions? I'm trying to use embedded data (for the first time), but this command doesn't seem to work - ${q://QID1%232/ChoiceGroup/SelectedChoicesCount/4}

Best answer by TomG

@mkosterich, The easiest way is to do it with JavaScript on a subsequent page and save the count to an embedded variable. Something like the following added to the addOnLoad function: ``` var countExtPain = "${q://QID2%232/ChoiceGroup/SelectedChoicesForAnswer/1}".split(",").length; Qualtrics.SurveyEngine.setEmbeddedData("countExtPain", countExtPain); ```
View original

4 replies

PeeyushBansal
Level 6 ●●●●●●
Forum|alt.badge.img+39
  • Level 6 ●●●●●●
  • 1144 replies
  • October 6, 2018
You can count how many time it appear by applying the branch in survey flow. Like if for first option extremely painful punch count =1...increment it for all. On your next question apply display logic using this embedded variable count.

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5929 replies
  • Answer
  • October 6, 2018
@mkosterich, The easiest way is to do it with JavaScript on a subsequent page and save the count to an embedded variable. Something like the following added to the addOnLoad function: ``` var countExtPain = "${q://QID2%232/ChoiceGroup/SelectedChoicesForAnswer/1}".split(",").length; Qualtrics.SurveyEngine.setEmbeddedData("countExtPain", countExtPain); ```

mkosterich
  • Author
  • 6 replies
  • October 8, 2018
Thanks for your help @bansalpeeyush29 and @TomG!

Forum|alt.badge.img+3

Hello -
I have a similar question. I need to count how many times "Deceased" is checked in a loop. I have a MC question with 5 options, the last being deceased. I need to count how many times it is checked so that i can delete it from the original number.
Here's the back story. I have a variable called tot_sibs - that's the number of living siblings my respondents have. I then ask about each sibling to see if any are dead. The loop will ask the same 3 questions for each sibling. I need to substract the number of dead siblings from the original "tot_sibs" variable to create this new "Sibling_count" variable. That variable will then be used to display certain questions. I took the suggestions above as well as this post but nothing is working.
https://community.qualtrics.com/XMcommunity/discussion/20806/counter-for-answers
This is the code I used. I tested each one separately and nothing. Any help is much appreciated!
Qualtrics.SurveyEngine.addOnload(function()
{ var Counter = "${q://QID243/ChoiceGroup/SelectedChoicesForAnswer/5}".split(",").length;
Qualtrics.SurveyEngine.setEmbeddedData("Counter", Counter); }

Qualtrics.SurveyEngine.addOnload(function()
{ if("${q://QID243/ChoiceGroup/SelectedChoices}" == "DO NOT READ: DECEASED") {
 var Sib_Counter = "${e://Field/Sib_Counter}";
 Qualtrics.SurveyEngine.setEmbeddedData("Sib_Counter", count + 1);}


Leave a Reply