Highlight Question Type | XM Community
Skip to main content

For highlight question types, I need to count the number of instances a category is used. I cannot find an option to set an embedded variable with the # instance where X category was highlighted.

 

Is there javascript to count instances? Or is there a way to count instances of a category with piping?

 

For example, you have a participant read a passage. Another person marks any instances where they read a word incorrectly. I want to be able to count the instances of ‘incorrects’. I can do this using regex and pivoting longer on the backend, but it would be better if there was a way to set the incorrect count in an embedded variable.

 

Thanks!

Kerry

You could try using JS to count the number of times a colon appears in the Piped text for a category and then set this in an Embedded Data field. So if the Piped text for the first category is:

1: This, 4: text, 7: highlight

Then counting the number of colons will give you the number of items for that category.

To give it a try, first create the Embedded Data field of “hlcat1” and put it at the top of the Survey Flow. Create additional Embedded Data fields for each HL category you want to count (hlcat2, hlcat3, etc.).

Then, in a question that comes on a page after the Highlight question, add the below to the question’s JavaScript in the OnReady section, updating the QID in the piping with the QID of the Highlight question:

var hlcat1 ="${q://QID32/ChoiceGroup/SelectedChoicesForAnswer/1}".split(": ").length - 1;
Qualtrics.SurveyEngine.setEmbeddedData("hlcat1",hlcat1);

Repeat for each HL category you want to count.


Leave a Reply