Performing calculations with numerical answers from a slider question | XM Community
Skip to main content

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!

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.


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


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


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


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

 


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


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


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


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