The steps below explain how to add logic to a follow-up question to a group of looped elements, based on the response to a question within the loop.
As an example, our loop pipes in brands of water that the respondent selects, indicating that they've tried them. One of the questions within the loop asks if they like the brand. We want to ask a follow-up question for one specific brand of water, if the respondent answers that they like that specific brand.
To learn about loop elements, click here.
Step 1: Identify the label of the loop variable that you wish to use in the logic.
In our example we only want to show our follow-up question to respondent's who have tried and like Brand C. Our loop element utilizes the responses to q3, which asks if the respondent has tried the water brands. We need to identify the label for Brand C, which we have set up as one of the piped variables in the loop element.
To identify the label for the piped variable, select the loop element so it appears in Builder's stage, then click "Edit Pipe Variables."
The "Pipe Variables Setup" window will appear. Locate the desired loop variable and make note of the label. Here we note that Brand C is r3.
Step 2: In the question within the loop element, identify the labels for the question and answer option that provide the desired response for the logic you want to create.
In our example, we want the follow-up question to show to respondents who have tried and like Brand C. Within our loop element, q4 asks if the respondent likes the brand, and r1 is Yes.
Step 3: Write the logic for the follow-up question.
At this point we have the information we need to write the logic for our follow-up question. We want to ask the question of respondents who answered that they have tried Brand C (
r3 of the looped variables) and like it (
q4.r1). Using the labels we collected in the last two steps, we write the logic as:
This logic means that if Brand C is being piped into the question text for q4, and the respondent answers that Yes, they like it, then the question will show.
Select the follow up question so it appears in Builder's stage, then select "Show If" and click "+New Condition." Click on "show raw code" to open the raw code editor, then enter the code in the area provided. Click "Save," or "Save As" to name the condition for later use in your survey.
The logic condition will appear for the question.
Step 4: Test.
Select "Test Survey" in the actions menu and test that the follow-up question shows when the correct answers are selected. Also be sure to test that the follow-up question does not show when the logic is not met.