Skip to content

Loops

Loops let you repeat the same sequence of questions multiple times, changing the text each time based on previous answers or a custom list you create. It’s like asking “How satisfied are you with [product]?” but swapping in different products without copy-pasting the same question over and over.

Example: A bank wants to ask customers about each type of account they have. Instead of creating separate questions for credit cards, home loans, and savings accounts, they set up one question set (Q2 & Q3) and loop it. The questions repeat automatically for each account type selected in Q1—neat, right?


Loops are indicated in the flowchart by a connector arrow (a loop line)—that’s your visual cue that questions will repeat. In Survey Editor (Beta), each question in the loop also shows “Loops under” and the loop driver’s code on its card. In the bank example, Q2 and Q3 will be asked once for each account type selected in Q1.

A couple of terms to know:

  • Loop driver — The variable that feeds into the loop (Q1 in the example). This must be a Multi question. In Survey Editor (Beta), it must use the Multiple Response - Checkbox format.
  • Loop iteration — Each time the questions repeat. If someone selects 3 account types in Q1, you’ll get 3 loop iterations where Q2 and Q3 are asked.

  1. Set up the loop driver

    Drag a Multi question to the flowchart and enter the question details: variable name, variable label, question text, and answers. Randomize the answers if you want the loop to present in a different order each time. And if you don’t want respondents to actually see this question (maybe you’re using an action command to auto-select answers), just hide it.

  2. Add the questions you want to repeat

    For each question in the loop, you’ll need to display the current loop value somewhere in the question text—something like “How would you rate your overall satisfaction with @Q1_CurrentLabel…”. Consider making this text bold or a different color so respondents can clearly see what’s changing between iterations.

  3. Create the loop

    Open the loop driver question’s menu and select Create Loop, then choose the last question to include in the loop:

    • Survey Editor (Legacy): choose it from the dropdown and click OK
    • Survey Editor (Beta): choose it in Final question in the loop and click Apply. Every question from the one after the loop driver down to the one you chose joins the loop.

    You’ll see a connector arrow in the flowchart indicating your loop.

    One last step: Click the loop driver in the flowchart and check the Use Loop Prefix box in the Properties Pane (look in the Loop section). This ensures that answers reset for each loop iteration—otherwise responses might bleed from one iteration to the next.


Open the loop driver question’s menu and select Edit Loop. To change which questions are in the loop, choose a different last question. To remove the loop, click Remove loop in Survey Editor (Beta).

In Survey Editor (Beta), a loop can’t contain another loop. Edit the inner loop first.


In the bank example above, respondents see the loop driver question and their selections determine how many times the loop runs. But sometimes you want to control this behind the scenes—maybe you’re looping through a preset list or testing specific scenarios. In these cases, use an Action Command to auto-select answers and hide the loop driver question.

To select all answers in the loop driver, use the SET action command. This selects everything available. Want the loop iterations in random order? Randomize the answer codes in the loop driver question.

In the bank example with 3 possible answers, SET will automatically select all 3.

To select only some answers, use SET to specify how many you want. Important: randomize the answers in the loop driver question, or you’ll always get the same codes (the first ones, according to sort order).

In the bank example with 3 answers, SET could auto-select just the first 2 according to Sort Order.

For more information, see Action commands and the Hide question property.


The number of loop iterations matches how many answers are selected in the loop driver. But here’s the thing: if your loop driver has 20 possible answers and someone selects them all, you’re asking them to go through the same questions 20 times. That’s a recipe for respondent fatigue (and probably some abandoned surveys).

To set a loop limit:

  • Click the loop driver in the flowchart
  • Enter the maximum number of loop iterations in the Loop Limit property (in the Loop section of the Properties Pane)

Example: In the bank scenario, imagine Q1 has 10 possible account types. Without a limit, someone who selects all 10 will answer Q2 and Q3 ten times. Set a loop limit of 3, and they’ll only answer Q2 and Q3 three times max—even if they selected all 10 account types. (Those who only selected one account type will still only see the questions once.)

Pro tip: Randomize the answers in your loop driver question so all codes have an equal chance of being included in the limited loop.


By default, Survey Shaper doesn’t track the presentation order of loop iterations when the loop driver is randomized. So you won’t know from the data which loop item was shown first, second, third, etc. But if you need to track this—maybe for analysis purposes—you can add a loop iteration stamp.

Here’s how:

  1. Drag a Single object to the position immediately after the loop driver question in the flowchart
  2. Select the Single Response - Numerical question format
  3. Open the object’s menu and select Action Command
  4. Enter a RECODE action command to capture the current loop driver value (Q1 in this example):
    WHEN 1=1 THEN @Q1_current END
  5. Click OK to close the Action Command dialogue box and Save the survey
  6. Test the action command to make sure it’s working, then hide the question so respondents don’t see it

Filter based on the answer to a question within a loop

Section titled “Filter based on the answer to a question within a loop”

Let’s say you want Q3 to only appear for accounts rated “fair” or “poor” in Q2. You’d apply a filter to Q3—but filters within loops are a bit trickier because you need to account for both the filter variable (Q2) and the current loop driver value (Q1).

Here’s what the Q3 filter would look like (assuming Q1 has 3 possible answers):

(@Q1_CurrentAnswer=1 and @Q1_loop_1_Q2>3) or
(@Q1_CurrentAnswer=2 and @Q1_loop_2_Q2>3) or
(@Q1_CurrentAnswer=3 and @Q1_loop_3_Q2>3)

Breaking this down:

  • @Q1_CurrentAnswer — The current value of the loop driver (Q1)
  • @Q1_loop_1_Q2 — The answer given to Q2 for the first loop driver value (Q1, Answer 1—Credit Card)
  • @Q1_loop_2_Q2 — The answer given to Q2 for the second loop driver value (Q1, Answer 2—Home Loan)
  • @Q1_loop_3_Q2 — The answer given to Q2 for the third loop driver value (Q1, Answer 3—Savings Account)

Want Q3 to only appear on the first loop iteration? Filter it based on the current loop driver value:

@Q1_Current=1

Here, @Q1_Current represents the loop iteration number.


Want all the questions in a loop to appear on a single page? No problem—just don’t put the loop driver on the same page as the looping questions. The loop driver needs to be on its own page (or grouped with other questions) for this to work.

For more details, see Page groups.


Right now, Survey Shaper doesn’t support conditional text within loops, except for displaying the current loop driver value using @loopdriver_CurrentLabel. So you can show which account type you’re asking about, but you can’t dynamically change other text based on previous answers within the loop.