Calculating Recode Values | XM Community
Skip to main content
Question

Calculating Recode Values

  • 9 September 2024
  • 5 replies
  • 61 views

Forum|alt.badge.img+2

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: 

 

5 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5779 replies
  • September 9, 2024

@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).


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 10 replies
  • September 9, 2024

@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
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5779 replies
  • September 9, 2024
sam.s77 wrote:

@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).

 

 


Forum|alt.badge.img+2
  • Author
  • Level 2 ●●
  • 10 replies
  • September 23, 2024

@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 :)


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5779 replies
  • September 24, 2024

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