Performing calculations with numerical answers from a slider question | XM Community
Solved

Performing calculations with numerical answers from a slider question

  • 4 April 2024
  • 9 replies
  • 47 views

Userlevel 3
Badge +7

Hi everyone! My question is regarding the possibility of manipulating participants’ responses on a slider question. We are working on a pilot test where participants are asked to provide a numerical answer (they have to provide a sentence in years after reading a fictional scenario).

For the next question, we want to tell them that the fictional judge provided a sentence 2 years longer than the numerical answer they provided. I tried to set an embedded data field in the survey flow, and set the value to calculate as their numerical answer provided earlier, plus 2. It looked like this: ${q://QID155/ChoiceNumericEntryValue/1} +2}.

Then, in the question describing the judge sentence, I added this embedded data field as piped text. However, the piped text does not show to respondents at all. I’m wondering if there is something wrong with the way the value was written, or if there is another way of achieving this with the help of Javascript. 

 

If someone is able to help, I would highly appreciate it. Thank you!

icon

Best answer by omkarkewat 4 April 2024, 14:05

View original

9 replies

Userlevel 5
Badge +12

Hi @Super_Recognisers I think the syntax is incorrect. It should be 

$e{ q://QID155/ChoiceNumericEntryValue/1 + 2 }. 

Make sure that the embedded data is defined before the judge sentence question.

Also please refer the math operations support page for more info.

Userlevel 3
Badge +7

@omkarkewat Thank you! I used the correct syntax this time (also, the math operations support page is quite useful in this sense). However, now only ‘2’ is displayed, so the numeric entry value was not picked up from the slider question. 

Userlevel 5
Badge +12

@omkarkewat I wonder what’s going wrong! can you share screenshot of your question and the embedded data.

Userlevel 3
Badge +7

@omkarkewat I attached the embedded data, as well as the 2 questions involved. The first one is asking participants for their initial sentence in years, and for the second one it’s supposed to show their answer + 2. 

Userlevel 5
Badge +12

@Super_Recognisers I doubt that you are piping in the value from the another question because the slider question doesn’t have any pipe options called “q://QID155/ChoiceNumericEntryValue/1”, it has options like 

So use $e{ q://QID155/TotalSum + 2 } and it should work.

 

Userlevel 3
Badge +7

@omkarkewat Thank you! Unfortunately TotalSum doesn’t work either. Not sure why.

I attached the piped text options that are showing up for me. I previously piped the “Sentence” one as that appeared to be the numerical value entry. 

Userlevel 5
Badge +12

@Super_Recognisers Instead of using embedded data, directly pipe text the value in between the question text where you need it - 

 As a result, the defendant received a higher sentence of $e{ q://QID155/TotalSum + 2 }, as decreed by the presiding judge.

Userlevel 7
Badge +27

@Super_Recognisers - The piped value you want to use in your math operation is ‘Sentence’. Also, the question that includes the math operation must be on the next page.

Userlevel 3
Badge +7

Thank you both for your replies! I believe it was a combination of the suggestions added here that finally made it work. I piped the value directly within the text question in this format: 

$e{ q://QID155/ChoiceNumericEntryValue/1 + 2 }

I used the ‘Sentence’ piped value as before, kept the initial structure of the embedded data in the survey flow, and added a page break between the two questions. Thanks very much for your help here!

Leave a Reply