Calculating Recode Values | XM Community
Skip to main content

Hello, I am trying to create a question to calculate a “Risk Score” based on answers to previous questions.

The previous questions contain recode values that are already in Qualtrics. Here is the intended calculation for Risk Score: If the count of the recode values is >= 17, then take the sum of the recode values. Otherwise, return “N/A” to the user. Attached below is what I currently have, but the output always comes out as Risk Score: “N/A” even when it should be returning a value. If anyone could provide any guidance as I am not proficient in Java Script, that would be greatly appreciated!

 

This is also a link to a prior conversation I was having regarding this problem but I am still having some confusion: 

 

@sam.s77 - I think your pipes are incorrect. Recode pipes have ‘Recode’ in the string (e.g., ${q://QID20/SelectedChoicesRecode}).  ChoiceNumericEntryValue is associated with numeric text inputs (e.g., constant sum question).


@TomG Are you referencing the pipes in the JavaScript or the pipes in the embedded data for RiskScore? Or both? I just updated the JavaScript pipes  but am unsure what the pipes in the embedded data RiskScore should be.


@TomG Are you referencing the pipes in the JavaScript or the pipes in the embedded data for RiskScore? Or both? I just updated the JavaScript pipes  but am unsure what the pipes in the embedded data RiskScore should be.

The pipes in the JavaScript (the recodeValues array).

 

 


@TomG Hi, Tom. I updated the JavaScript for the recode values array, but I am still only getting “Risk Score: N/A” when I preview the survey and should be getting a calculated value. Do you see any other problems with my code? I appreciate all the help :)


Not off-hand. The logging of recodeValues and validValues should give you a clue.


Leave a Reply