You can import this example into your own Qualtrics account by downloading this file.
1. Create the questions
Create the questions. We will perform math operations on the responses to these questions. In the example, I have renamed the questions “A,” “B,” and “C.”
2. Create embedded data variable(s)
Create an embedded data variable in the survey flow as shown here. Create as many separate embedded data elements as you wish to store for future use. Future uses could be as branch logic in the survey flow, display logic for future questions, or to display the value you created as piped text.
Insert this code:
What this does
Now finally, it does the math. There are two math functions performed. The first is a function to see what the highest response was to questions A, B, and C. The second equation plugs the user’s answers into a regression equation.
The line of code after the math functions displays the “utility” calculated in the regression equation in the question itself. Note that in order for this to work, you must create an HTML “div” element in the question with the “id” attribute of “toReplace.” You don’t need to display the output of the calculation in this question if you don’t want to. This is simply one way to do it.
Finally, the code saves the calculated values as embedded data. You can see usage examples as piped text in the block which follows it.