Nested Group Logic is an advanced form of Group Logic that rotates a set of questions within a larger set of rotated questions. This streamlines complex concept testing and reduces order bias in respondent data. It is sometimes called "group within group" logic.
Learn more in the Lighthouse Academy course, Group Logic & Smart Loops!
In This Article
Syntax
Nested Group Logic syntax includes:
- the command Group
- question references—write a range as
Q13-14; questions inside a range always appear in order - parentheses—to create a nested group. Each set of parentheses is its own group and can take its own subcommands
- the operator and—to separate the nodes at every level, both the larger nodes and the questions or groups nested inside them
- the operator then—to set a fixed order inside a set of parentheses. Everything before then is shown first. then only works inside parentheses
- the subcommands max, balance, randfill, and leastfill, as desired. Placed inside a set of parentheses, a subcommand applies to that nested group only
⚠️ Note: All questions in one group command must form a single continuous block with no gaps and no question listed twice. Only main survey questions can be grouped (not pre-survey questions), and a single range can't span 100 or more questions. Write ranges as
Q6-7, notQ6-Q7—the second form is a syntax error.
💡 Tip: By default, every level uses leastfill: each respondent gets the node that has been shown least often at that position so far, which keeps exposure even across respondents. Add randfill inside a set of parentheses (or at the end of the command for the top level) to pick nodes purely at random instead.
Examples
[group (Q13-14 and Q15-16) and (Q17-18 and Q19-20) and (Q21-22 and Q23-24)]
Three nodes are rotated (shown by the three sets of parentheses). Within each node, two batteries are also rotated. In the first node, the respondent could see Q13–14 first or Q15–16 first.
[group (q2-3 then q4 and q5) and (q6-7 then q8 and q9)]
Two nodes are rotated—some respondents see Q2–5 first, others see Q6–9 first. Within each node, the questions before then always come first (Q2–3 or Q6–7), and the questions after then (Q4 and Q5, or Q8 and Q9) are shown in rotated order.
[group ((Q13-14 and Q15-16) and (Q17-18 and Q19-20)) and ((Q21-22 and Q23-24) and (Q25-26 and Q27-28))]
Three levels of group logic: two large nodes (Q13–20 and Q21–28) at the highest level. Within each, two additional nodes, each containing two rotated batteries.
[group (Q26-27 then (Q28 and Q29 and Q30 max 1)) and (Q31-32 then Q33 and Q34) and (Q35-36 then Q37 and Q38)]
Three uneven parent nodes. In the first, respondents see Q26–27, then one of Q28, Q29, or Q30 (with the default leastfill, the one shown least often so far). In the second, respondents always see Q31–32 first, then Q33 and Q34 in rotated order. In the third, respondents always see Q35–36, then Q37 and Q38 in rotated order.
Placement
Group logic applies to the whole survey, no matter which question you type it into. We recommend typing it into the first question of the group, or the first question of the survey, so it's easy to find later.
⚠️ Note: Typing group logic into a conditional question does not limit it to respondents who saw that question—every respondent who reaches the grouped questions follows the group. To control who sees grouped questions, add show or hide logic to those questions.
Using Nested Group Logic in Smart Loops
- With all Smart Loop questions programmed, set Assign runs to Static Order. The loop then shows All runs/respondent automatically. The other options (Evenly and Randomly) add their own group logic to the loop, which would conflict with yours.
- Type the Nested Group Logic into any question, including parentheses and/or the then operator. Reference each run by its own question numbers: every run of the loop gets separate numbers. For example, a Smart Loop that starts at Q5 with two questions and three runs becomes Q5–6, Q7–8, and Q9–10.
- Use the Preview tool in Respondent mode or Researcher mode to confirm the question numbers each run receives and that pathing works as expected.
Virtual Question Presets
When a survey has Group Logic, the Optional Presets menu of Virtual Question on the Results page lists matching questions under a Group N: heading.
For Nested Group Logic, presets come from the top level only. Each top-level node is read as one list of questions, in the order they're written, and the questions in the same position across nodes are offered together as one preset. Nested levels don't get presets of their own. In the first example above, Q13, Q17, and Q21 form one preset; Q14, Q18, and Q22 form the next; and so on.
| Group shape | What appears in the presets |
|---|---|
| Parallel (every top-level node has the same number of questions, with matching types) | One preset per position. |
| Uneven (nodes differ in length or question types) | Presets for the leading positions that line up across nodes (same question type and number of answers). Positions after the first mismatch, or present in only one node, are left out. In the last example above, Q26/Q31/Q35 through Q29/Q34/Q38 can appear; Q30 can't. |
Each preset needs at least two questions of the same type, subtype, and number of answers. Slider questions are not offered as presets.