Change subsequent question text based on selected choice | XM Community
Skip to main content
I have a survey with a multiple choice question containing 54 values. A user will never see more than 9 values/options due to display logic controlling the visibility. I need to be able to display different text (or piped text) in subsequent questions. For example, in the multiple choice question a user may select "job shadow" or "performance group." In a subsequent question (labeled "Organization Name"), I want to display additional text based the previous selection. In this case, if the user selected "job shadow," I want to display "Enter the name of the organization where you shadowed." If the user selected "performance group," I want to display "Enter the name of the performance group."
Hi,



This can be done with the loop and merge function. https://www.qualtrics.com/support/survey-platform/survey-module/block-options/loop-and-merge/
> @uhrxx005 said:

> Hi,

>

> This can be done with the loop and merge function. https://www.qualtrics.com/support/survey-platform/survey-module/block-options/loop-and-merge/



Loop and Merge does not address the issue here.
Why couldn't you just create new fields within loop and Merge with the language you want "Enter the name of the organization where you shadowed."



Then pipe those fields in as needed.
The subsequent questions asked based on the selected choice in the first question varies greatly. Also, the export file generated by Loop and Merge creates nearly 1,000 columns of mostly null values. I need to be able to import the data into Excel, quickly manipulate, and prepare to import into another system.
> @ambrubaker said "A user will never see more than 9 values/options due to display logic controlling the visibility."



Could you explain the 9 values comment? I can't tell if these are 9 values within the list of 54 values or something else. And is this multiple choice question checkbox or radiobutton type (multiple or single value)?



It would probably be easiest to simply share a copy of the .qsf survey file so we have a better idea of your survey layout.
@"w.patrick.gale",



The list of 54 values is one multiple choice question with "Answers" set to "Single Answer" (radio button type). I have display logic set for each answer choice within this list so that any given user will not see more than 9 total answer choices when they take the survey.



I have attached a .qsf file with the display logic for answer choices set on some of the items (I'm still working through setting the logic on the others).
The way I see it you having two options. One being the less technical way of separating your questions into separate blocks and adding branch logic in the survey flow between each question to set embedded data values to use as your subsequent question text.



The second way is to write some javascript to update embedded data values (in your case the question text). So you could have an embedded data variable called strOrgQText (for Organizational Question Text) that is set in the javascript when the lead-in question is submitted. If you know javascript then I suspect you get the gist of it. If you are new to creating surveys and not familiar with javascript I would go with the first option of branch logic and splitting your questions across blocks.
@ambrubaker Thanks for including the survey, that helps. I looks like your layout fits well with adding additional branch logic in the survey flow to set embedded data values for your question text within your activity blocks. Does that make sense? (nice looking survey by the way)
@"w.patrick.gale" If I am understanding your suggestion correctly, I would need to create an embedded data element for every possible text item I would want to display? Not sure if that makes sense or not.



I was curious if there might be a way to use a if-then statements in JavaScript on each question to update the text label. I'm familiar enough with JavaScript to be able to interpret and understand how the code is working, but not knowledgeable enough to write my own code from scratch.



This is basically what I am thinking (pardon the non-technical writing).



IF "activity" = "job shadow" THEN "display_text" = "Enter the name of the organization where you shadowed."

OR

IF "activity" = "performance group" THEN "display_text" = "Enter the name of the performance group."
@ambrubaker,



Include both the choice text and pipe text in your choices inside span tags with a class:

```

<span class="choiceText">Job shadow</span><span class="pipeText">organization where you shadowed</span>

```

Then use JS to hide the ones you don't want displayed. In your initial question you don't want to see the piped text, so:

```

jQuery(".pipeText").hide();

```
@ambrubaker You do not necessarily need to create a separate embedded data variable for every possible text item, but rather for change the variable value depending on the response chosen (it is the same thing whether you are using branch logic or javascript).



You should be able to use the branch logic as an if/else statement for simplicity. Just create an embedded data field (maybe call it 'strDisplayText') to store the 'display_text' value for your subsequent question. In you branch logic if the question containing the "activity" = [something] then set the embedded data variable 'strDisplayText' = [whatever]. You can overwrite the strDisplayText variable in the branch logic between questions (assuming you don't allow users to go 'back' in the survey, in which case you probably would want a separate variable for each subsequent question).



!



Clear as mud?

What does this end up looking like in the survey Report tab / Data sub-tab?
Normally, we would see the question text, along with some default data visualizations (e.g. bar chart, stats for the question, answer counts).
If the question text changes per survey participant (depending on the previous answer), what appears in the survey text for the Report?
I suppose I'll find out when I try this next week, but I was just wondering if you knew the answer based on your experience.
This is important to me because I really do want to have a generated report (vs. having to massage data manually).
Thanks.


Leave a Reply