Performing calculations with default choices | XM Community
Skip to main content

I have two questions with slider answers. Let's call them for simplicity, Q1 and Q2
I want the answer to Q2 to:
1) always display read-only
2) be what participant selected in Q1 plus a randomly selected number from the following set : (0,10,100,-10,-100).

So Q2 = Q1 +i, where i randomly takes value from the set (0,10,100,-10,-100). 

I wonder whether anyone has done something similar in the past and can help me.
I am new to qualtrics and also new to JavaScript.
I only managed to pass Q1 answer to Q2 answer by using the
Any ideas?
Thank you

Hi there,
Yes you can do this. It is a combination of piped text and the loop and merge function. You will either have to put the questions in two different blocks or in the same block with a page split between each. I find the former easier and less clunky. Below is the example of doing it with the questions in two different blocks.
Step 1) create block for Q1 (multiple choice question I assume)
Step 2) create block for Q2 (multiple choice question I assume)
Step 3) for one of possible choices for Q2, click the drop arrow next to "click to write choice X" -> select "insert piped text" -> select "survey question" -> select survey question Q1 -> select "selected choices".
Step 4) for the block that Q2 is in, click the overall block and turn on the loop and merge function under block behavior.
Step 5) reduce the fields so that there is only one column. Insert the potential numbers that they can receive randomly (e.g., 0, 10, 100, -10, -100).
Step 6) select randomize loop order, select present only ___ loops. fill in the black to be "1". **this will randomly display only 1 of the numbers you have placed in the field.
Step 7) go back to Q2 and for another possible choice click the drop arrow next to "click to write choice X" -> select "insert piped text" -> select "Loop and Merge" -> select "Loop and merge field" -> select the field you put the numbers in (you should see them displayed and it is most likely field 1).
That should do it. What is nice about this is that it doesn't use any external javascript, so all of qualtrics functions will work as normal.
*very important, make sure that in the potential choices the only thing that is displayed in your view is the code that begins with $ and ends with }. If there is other text before or after it, you should remove it otherwise it will also display it.
**very important pt2. The code qualtrics uses here relies on question IDs. If you change question IDs after this, I am not sure the code will automatically update. You should then double check.
***very important pt 3. If participants fail to answer Q1, there will be nothing displayed as one of their options in Q2.
*very important pt4. When you download the data, there will be a column for each of the possible displays in Q2. For example, there will be a column for if participants were shown 1, 10, and 100. If the column is empty, that means that they were not shown that potential choice. If the column has a value in it, that value you tells you that they were shown that potential choice (e.g., 100) and what they chose.

Happy to discuss more if this is helpful or if you have questions.


Thank you! Thank is super useful and it worked.
Best,


https://community.qualtrics.com/XMcommunity/discussion/comment/43361#Comment_43361Very welcome! Best wishes.


Leave a Reply