Exporting text entry responses as a count/number | XM Community
Skip to main content
Solved

Exporting text entry responses as a count/number

  • July 15, 2022
  • 2 replies
  • 101 views

Forum|alt.badge.img+1

Is there a way to export a written response to a Text Entry question as a count of listed items/word count?

For example, if my prompt was "list all of the vegetables that you like," and my respondent answered "carrots, broccoli, green beans, asparagus," I would want this to export as "4" instead of the list of vegetables.

I am still in the process of formulating the question, so I could instruct respondents to separate items with commas, periods, etc., if that would help at all. I plan to export to SPSS.

Best answer by MadelineB

https://community.qualtrics.com/XMcommunity/discussion/comment/47772#Comment_47772Hi TomG,
Thank you so much! I moved .length to the line above and it worked.
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var veggies = jQuery("#"+this.questionId+" .InputText").val().split(",").length;
Qualtrics.SurveyEngine.setEmbeddedData("veggieCount",veggies);
});

2 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • July 15, 2022

Define 'veggieCount' as an embedded data field in the survey flow and then update it with JavaScript attached to the question (assumes vegetables are separated by commas):
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var veggies = jQuery("#"+this.questionId+" .InputText").val().split(",");
Qualtrics.SurveyEngine.setEmbeddedData("veggieCount",veggies.length);
});


Forum|alt.badge.img+1
  • Author
  • Answer
  • July 19, 2022

https://community.qualtrics.com/XMcommunity/discussion/comment/47772#Comment_47772Hi TomG,
Thank you so much! I moved .length to the line above and it worked.
Qualtrics.SurveyEngine.addOnPageSubmit(function() {
var veggies = jQuery("#"+this.questionId+" .InputText").val().split(",").length;
Qualtrics.SurveyEngine.setEmbeddedData("veggieCount",veggies);
});