> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sprig.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Loop and Merge

> Ask the same follow-up questions for every answer, number, or item, without duplicating questions.

> [!NOTE]
>
> Loop and Merge is available for customers on the Enterprise plan in link Surveys.

Loop and Merge repeats a question or a block of questions in your Survey. Each repeat, called a loop, fills in its own wording, so respondents see "Have you ever seen Tool live?" and then "Have you ever seen Salmo live?" from one question you wrote once.

Use it to:

* Ask follow-ups about each product, brand, or feature a respondent selected
* Ask about each item in a count, like each concert someone went to or each pet they own
* Ask the same questions about a fixed list, like three product concepts or genres

## How Loop and Merge works

You turn on Loop and Merge for a single question or for a block. Everything inside it repeats once per loop, in order, before the Survey moves on. Respondents don't see anything labeled as a loop. They only see questions whose wording matches each loop.

| Loop type | Repeats once for each | Source |
| :- | :- | :- |
| **Loop from question** (multi-select) | Choice that matches your **Selection**, for example each choice the respondent selected | An earlier Multiple Choice Multi-Select question |
| **Loop from question** (number) | Number up to the respondent's answer, for example three loops for an answer of 3 | An earlier Validated Text question set to Numeric |
| **Static loop** | Value in a list you type in, the same for every respondent | None |

For example, Q2 asks "Which artists have you listened to the most over the past year?" A block with Q3 and Q4 loops from Q2. A respondent who picks Tool and Salmo answers Q3 and Q4 about Tool, then Q3 and Q4 about Salmo.

## Set up a loop

1. Open a draft link Survey in edit mode.
2. Select the question or block you want to repeat, and open its **Loop & Merge** tab.
3. Turn on **Enable Loop & Merge**.
4. Choose **Loop from question** or **Static loop**.
5. For **Loop from question**, choose the **Source question**. It must be a Multiple Choice Multi-Select question, or a Validated Text question set to Numeric, that comes before the loop.
6. For a multi-select source, choose the **Selection**. **Selected choices** is the default.
7. Optional: check **Max loop** and enter the most loops a respondent should see.
8. Under **Define fields wording to use for each loop**, name each field and enter a value for each loop. For a static loop, use **Add Value** to add one row per loop.
9. Add the fields to your question text with **Piping**.

A green loop icon shows next to the name of every question or block with a loop. Turning Loop & Merge off keeps your settings, so you can turn it back on later.

> [!NOTE]
>
> If the **Source question** list is empty, there is no eligible question before the loop. Single-select questions can't be a source. Add a multi-select or numeric Validated Text question earlier in the Survey.

## Choose which choices repeat

When the source is a multi-select question, **Selection** decides which of its choices get a loop. Hover the info icon next to each option in the builder for a reminder.

| Selection | Loops once for each |
| :- | :- |
| **All choices** | Choice in the source question, whatever the respondent selected |
| **Selected choices** (default) | Choice the respondent selected |
| **Unselected choices** | Choice the respondent didn't select |

## Limit the number of loops

Use **Max loop** to keep long Surveys short. A loop can have up to 10 values, and Max loop can't be higher than the number of values.

* **Multi-select source:** if a respondent qualifies for more loops than the max, Sprig picks which choices to loop at random.
* **Number source:** the respondent sees loops 1 through their answer, stopping at the max. With a max of 4, a respondent who answers 6 sees four loops.
* **Static loop:** the respondent sees the first values in your list, up to the max.

## Add loop fields to your questions

Fields hold the wording that changes from loop to loop. Each field has a name and one value per loop, and a loop can have up to 10 fields.

* **Multi-select source:** the first field is always **Choice**, the label of the choice being looped. Add more fields for other wording, such as a short name or a category.
* **Number source:** name a field, for example **Number**, and enter a value for each loop, such as 1st, 2nd, and 3rd.
* **Static loop:** name every field yourself and fill in one value per loop.

To use a field, open a question inside the loop, click **Piping** in the question text toolbar, and pick the field from the **Loop & Merge** section. The field shows as a chip in the builder. Respondents see the value for their current loop as plain text, so "Which ticketing platform did you use for the \{Number} concert?" reads "Which ticketing platform did you use for the 2nd concert?" in the second loop.

## Respondent experience

Respondents answer the looped questions once per loop, in order, then continue with the rest of the Survey.

* If there is nothing to loop over, for example no choices selected or a number source answered with 0, the loop is skipped.
* Each loop is saved as its own answer, so respondents can give a different answer for each one.
* Translations are created from the original question, so each loop is translated with its own values filled in.

## Use loops with logic and blocks

* **Display Logic and Skip Logic:** aren't available on a loop or the questions inside it. Loops from a question use their source to decide who sees each loop.
* **Randomization:** a loop always stays together. In a randomized block, it moves as one unit and its loops keep their order.
* **Blocks:** you can loop a whole [block](https://docs.sprig.com/docs/shared-study-foundations/main-tasks/blocks.md) or a single question, but not both. A question inside a looping block can't have its own loop.
* **Moving questions:** the source question must stay before the loop. You can't move a loop above its source.

## Review loop results

### Data tab

Each looped question appears once, with its number, question type, and a loop label:

* **Loop source Q2** when it loops from a multi-select question
* **Loop source Q5 - Max 4 loops** when it loops from a number question with a max
* **Static Loop** when it loops over a static list

Under the label, every loop gets its own result: the question text with that loop's value as a chip, its own responded count, and its own chart, response table, or AI summary of open-text answers. For example, "Have you ever seen Tool live?" and "Have you ever seen Salmo live?" each show their own Yes and No bars, so you can compare them. You can pin each loop to a Dashboard on its own.

### Responses tab

In each respondent's response, looped questions are grouped under the same loop label. The question text shows the field name, such as Choice, and each answer row shows the loop number, that loop's value, and the answer, for example Loop 1, Tool, Yes. Only the loops a respondent saw are listed.

### CSV exports, webhooks, and integrations

Each loop is its own question and column, labeled with its wording filled in.

## Edit a loop after launch

Once your Survey has its first response, the loop type, source, Selection, Max loop, fields, and values are read-only. You can still edit other parts of the Survey.

## FAQs

> [accordion] Can I use a single-select question as a source?
>
> No. A source must be a Multiple Choice Multi-Select question or a Validated Text question set to Numeric.

> [accordion] Can I put a loop inside another loop?
>
> No. A question inside a looping block can't have its own loop.

> [accordion] How many times can a question loop?
>
> Up to 10 times. A loop can have up to 10 values and 10 fields.

> [accordion] What happens if a respondent selects nothing?
>
> The loop is skipped, and the respondent continues with the next question after it.

> [accordion] Can I change a loop after launch?
>
> Not after the first response. Loop settings become read-only so results stay consistent.
