Looping is the ability to setup a series of options, either manually or copied from a previous element, and pipe individually through a series of shared questions. Loop allows you to repeat each question for each option that the respondent is either aware or not aware of based on defined criteria. This feature replaces the need to create multiple questions for each option by using a shared set of questions. Each option will have its own output in the data and reporting.
In this example we will ask a series of questions about the types of soda the respondent has tried.
1: Adding a Source Question
The source question will be used to pipe in variables for the looped elements. This question cannot be a 1-dimensional single-select question.
Tip: It is possible to manually input the variables that pipe into looped elements; the variables used for the pipe do not have to be based on responses to a question. If you want to manually input the options, skip this step and start with step 2.
Add a new survey element and enter the answer options.
2: Adding the Follow-up Questions
Note: The follow-up questions will be added to the loop element in a later step.
Add the first question on a new page and enter the question text and answer options. You may add a marker or leave a blank space where the pipe will occur. Add each additional follow-up question in the same manner (page breaks are not required).
3: Inserting the Loop Element
The loop element should be placed after the source question and before the follow-up questions.
Select the source question in the question tree so it appears in the stage area. Insert a page break after the question. To insert a loop element, add a new survey element, select "Structural" and choose "Loop". Then click "Insert":
For "manual input" (i.e., if you're not using a question for the source of the piped variables), click on the first of the follow-up questions and add the loop element before it. In the "title" field, enter a title for the loop. Next, select "edit pipe variables" to add variables to pipe into the looped elements:
4: Building the Loop - Add Variables
The "Pipe Variables Setup" window will appear. At this point, you may either manually input the loop source or select a question that occurs before the loop and utilize the answer options as the loop source.
Tip: Keep in mind that the respondent will have to answer each of the questions for every loop iteration, so the more loop iterations the longer the survey time will be.
4.1: Manually Input the Loop Source
In the "Loop Source" dropdown menu, select "manual input".
Follow the numbered guide below to manually input the loop source.
1. Label Suffix: A label suffix will automatically be assigned to each row (i.e., loop iteration). To edit a label, delete the default and enter a new value.
2. Condition: Assign a logic condition for individual loop iterations. By default each row will show to "all" respondents. To edit a condition, click on the link for the row and define the condition. To learn more about building logic conditions, click here.
3. Var: System generated variable label. The variable column contains a variable that's available inside each loop iteration.
4. Add Variable: Add a new variable and specify alternate text for the loop iterations.
5. Delete: Delete a row (i.e., loop iteration).
6. Add Row / Value: Add a new row (i.e., loop iteration).
7. Shuffle Variable Order: Check this box to enable shuffling for the loop iterations.
8. Save: Save the settings.
4.2: Use a Question for the Loop Source
In the "loop source" dropdown menu, select a question. Questions that cannot be used as a loop source will appear in grey. We selected the question we added in step 1, "q4: Which of these soda brands have you tried?".
The answer options for the question will appear in the window. Follow the numbered guide below to setup the pipe variables. In this example we want to loop only the soda brands the respondent has tried, so we selected q4 as our loop source, checked the box for "loop if" and chose "selected". The conditions for each row will update accordingly.
1. Loop if: Check this box to loop the rows based on how the respondent answers the source question. Choose "selected" to loop only the answer options the respondent selected in the source question; choose "not selected" to loop only the answer options the respondent did not select in the source question.
2. Label Suffix: A label suffix will automatically be assigned to each row (i.e., loop iteration). To edit a label, delete the default and enter a new value.
3. Condition: Assign a logic condition for individual loop iterations. By default each row will show to "all" respondents if "loop if" is not enabled. To edit a condition, click on the link for the row and define the condition. To learn more about building logic conditions, click here.
4. Variable: System generated variable label for the source question. The variable column contains a variable that's available inside each loop iteration.
5. Add Variable: Add a new variable and specify alternate text for the loop iterations.
6. Delete: Delete a row (i.e., loop iteration).
7. Delete condition: If a logic condition is specified and you wish to remove it, click the "x" next to the condition and it will reset to "all".
8. Add Row / Value: Add a new row (i.e., loop iteration).
9. Shuffle Variable Order: Check this box to enable shuffling for the loop iterations.
10. Save: Save the settings.
5: Building the Loop - Add Looped Elements
Once the pipe variables have been setup you can add elements to the loop element. Only elements that appear after the loop element can be added to it, and they must be added in descending order. In the "Looped Elements" section, click the "add to loop" link that appears with the question label and text. The changes are displayed in the question tree.
6: Inserting the Pipes
Once the loop element has been setup, click on the first question in the loop in the question tree to add the pipe.
Click in the position in the question text where the pipe will occur. Select the pipe tool in the toolbar, then select the loop element (i.e., "loopvar: q_").
The pipe will appear in the question text. Repeat this step for each of the follow-up questions in the loop element.
7: Nesting Loop Elements
You can also nest one loop element within another to randomize a second set of elements. To create a loop within a loop, simply follow the steps above, inserting the new loop after the first loop:
For example, if you wanted to randomize the questions about soda availability within soda brands, you might nest your store questions within your soda brand loop:
7.1: Nested Loop Limitations and Considerations
There are a few things to keep in mind when nesting loops:
- The maximum number of expanded looprows is 500; this means that if you had three nested loops with 10 looprows each, you would receive an error message for exceeding the maximum (10 looprows * 10 looprows * 10 looprows = 1,000 looprows).
- While there is no limit on the number of nested loops you can have within a survey, each additional loop will increase survey load time.
Click here for more nested loop customization options.
8: Testing the Loop Element
To test that the loop has been setup correctly, click on the builder menu and select "Test Survey". Proceed through the survey to the loop element. For our example we want to ask additional questions about each soda brand the respondent selects in q4, in this instance, Coke, Sprite and Dr. Pepper.
We see the series of looped questions, which ask us about the first brand we selected, Coke:
We are shown the same series of looped questions, which now ask us about the second brand we selected, Sprite:
Finally, we are shown the same series of looped questions, which now ask us about the last brand we selected, Dr. Pepper: