Coding and math calculations | XM Community
Skip to main content

Hi,
I am creating a calculation based on several products that have been chosen i previous questions
They are all Multi choice, one answer questions.
Q13 - has 8 levels and the value of the levels are recoded to the price of the product. Eks level 1 is 599, level 2 is 549, ect.
Q14 and Q15 are recoded to the amount of products they choose. So 1 level 1 is 0, Level 2 is 1, ect..
I need a formula like this:
$e{ q://QID14/SelectedChoicesRecode * 449 + q://QID15/SelectedChoicesRecode * 349 + q://QID13/SelectedChoicesRecode },-
But it is invalid.
If I remove Q13 and replace it with a zero, the syntax works for the two other variables. But it becomes invalid when I remove the zero. This I find strange. If I only go the syntax for selected choices recoded, the Q13 number is displayed correctly.
$e{ q://QID14/SelectedChoicesRecode * 449 + q://QID15/SelectedChoicesRecode * 349 +0 },-

I've tried a number of combinations, but I am found at a lost. Any help is much appreciated.
Best,
Lise Kristiansen

Math operations are very very very finicky. Have you tried splitting up the calculation into 2 parts?
This is easily done in JS, but I would recommend you try that, so that you have more control over any changes required in the future?


Lise_Kristiansen This could be a problem with blank spaces. If you are editing the calculation in a survey question, switch to the HTML view. In your calculation, there should be a blank space separating every single term. If you see somewhere a blank space has been converted to the HTML

 
then you need to change that to a blank space. Do that while in HTML view by just overwriting the
 

image.pngimage.pngIt also looks like in the second calculation you wrote, you don't have a blank space separating the final term
+0
. You would probably need to change that to
+ 0
and again, double check the HTML view to make sure you've entered a space that hasn't been converted to
 


https://community.qualtrics.com/discussion/comment/38395#Comment_38395That did the trick! Thank you very much 🙂!


Leave a Reply