How to create text fields that give strings based on, but not identical to, answers to previous Qs? | XM Community
Question

How to create text fields that give strings based on, but not identical to, answers to previous Qs?


Badge
Say Question 1 says "What product are you interested in? (a) Shoes, (b) Shirts, (c) Pants" and Question 13's text _depends_ on the answer from Question 1, but it's not going to repeat the text exactly. For instance, "Imagine you were shopping for {Question 1 answer - if a: "boots"; if b: "polos"; if c: "jeans"}. Which of the following..." Is there a way to do this with, say, piped text? I can't use logic and just copy the questions with slightly different text because I have at least 20 of these conditionals, and it would quickly get extremely unwieldy. I feel like piped text would be the ideal way to do it, but I don't know how since I've never used it and the only things I've been able to do with it so far have been repeated text that already exists, rather than creating conditionals.

7 replies

Userlevel 7
Badge +19
Have you taken a look at the loop and merge function? It's usefulness might be dependent upon your use-case. But it does allow for you to hold similar statements and pipe in just the right type of text for the right condition:

https://www.qualtrics.com/support/survey-platform/survey-module/block-options/loop-and-merge/

!
Userlevel 7
Badge +27
@AGBS - see this post:
https://www.qualtrics.com/community/discussion/comment/15688#Comment_15688
Badge
@Kate said:
> Have you taken a look at the loop and merge function? It's usefulness might be dependent upon your use-case. But it does allow for you to hold similar statements and pipe in just the right type of text for the right condition:

Thanks for your suggestion. I've considered loop & merge, but I'm not completely sure how it works and I'm concerned that it will quickly become problematic if I have nested conditionals. For instance, the first question might ask what product the person is interested in, the second question might ask how much they spend on that product per year, and the third question might ask which store they typically buy from. Assuming each new question has a reference to the participant's answer on a previous question, I'll end up with 3x3x3=27 different versions of Question 4. Given that I have roughly 20 conditionals, I'll end up with 3^20 versions. Will loop & merge help me manage that?

Edit: I should clarify, when I say there will be 3^20 versions, I'm not just worried about having a clunky backend, I'm concerned because I need to treat all 3^20 versions of Question 4 as identical questions when I'm analyzing the responses.
Badge
> @TomG said:
> @AGBS - see this post:
> https://www.qualtrics.com/community/discussion/comment/15688#Comment_15688

Thanks for the link. I don't know JavaScript, but from what I can tell, that comment is only showing how to hide/show text and not how to obtain the value of the participant's choice from the previous question. The latter part is the problem that I'm trying to solve: does something in that thread show how to do that?
Userlevel 7
Badge +27
> @AGBS said:
> > @TomG said:
> > @AGBS - see this post:
> > https://www.qualtrics.com/community/discussion/comment/15688#Comment_15688
>
> Thanks for the link. I don't know JavaScript, but from what I can tell, that comment is only showing how to hide/show text and not how to obtain the value of the participant's choice from the previous question. The latter part is the problem that I'm trying to solve: does something in that thread show how to do that?

You can pipe or carry forward the answer(s) from a previous question.
Badge
> You can pipe or carry forward the answer(s) from a previous question.

Thanks, I understand the piping part, and I've figured out how the JS part works, but it doesn't solve the problem of hiding the text for choices that the participant _didn't_ choose. All this JS code does is switch from the choice text to a different text, but the whole point is only showing participants text contingent based on what they previously chose, so how do I show them _only_ what they chose?
Userlevel 7
Badge +27
> @AGBS said:
> > You can pipe or carry forward the answer(s) from a previous question.
>
> Thanks, I understand the piping part, and I've figured out how the JS part works, but it doesn't solve the problem of hiding the text for choices that the participant _didn't_ choose. All this JS code does is switch from the choice text to a different text, but the whole point is only showing participants text contingent based on what they previously chose, so how do I show them _only_ what they chose?

Again, carry forward the selected choices from the first question to the second question. Then use JS to hide the part of choices you don't want them to see.

Leave a Reply