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

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.

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);
});


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);
});


Leave a Reply