Group Logic allows you to randomize questions or sets of questions within a survey. Most commonly used for monadic or sequential monadic survey design, it can also be used to randomize a small number of consecutive questions.
In This Article
- The Basics
- Single Questions
- Question Sets
- Question Numbering Rules
- Max Qualifier
- Advanced Grouping: Balance
- Group Assignment
- Nested Group Logic
- Additional Rules and Behaviors
The Basics
A single logic statement starting with [group...] sets the rules that determine how respondents are directed through the groups in your survey flow.
Group logic can be entered into any question field in the survey. The statement is collected survey-wide, and the group activates as soon as a respondent reaches any question that is a member of the group—not when they reach the question the statement happens to be written in.
💡 Tip: Place the statement in the first question of the group or in a question that precedes it. Placement doesn't change behavior, but it keeps the logic easy to find and maintain
Single Questions
To randomize the order in which respondents see certain consecutively programmed questions, enter this logic into the first question within the group or into a preceding question:
[group Q2 and Q3 and Q4]
When respondents reach any of these questions, they are routed through all three in a varied order. Once they complete all three, they proceed to the next available question.
The order is determined by the assignment method, which defaults to least-fill rather than pure randomization—see Group Assignment. To randomize the order independently for each respondent, add randfill.
Question Sets
To vary the order in which respondents see sets of questions (also called nodes or paths), enter the logic into the first question of the first group, or into any preceding question:
[group Q1-3 and Q4-6 and Q7-9]
Questions within a set (Q1, Q2, Q3) are shown in order, but respondents will start with Q1, Q4, or Q7 in a varied order. Once respondents complete all questions in all three sets, they proceed to the next relevant question.
Question Numbering Rules
Every question number referenced in a single group statement must form one consecutive, gapless block, with no number used twice. This applies across the whole statement, not within each set.
| Statement | Result |
|---|---|
[group Q1 and Q2 and Q3] |
Valid—Q1–Q3 are consecutive with no gaps or repeats. |
[group Q1-3 and Q4-6 and Q7-9] |
Valid—Q1–Q9 form one continuous block. |
[group Q1 and Q5 and Q9] |
Invalid—gaps between the question numbers. |
[group Q1-3 and Q3-5] |
Invalid—Q3 appears in two sets. |
⚠️ Note: An invalid statement is dropped silently. No error is shown, and the survey fields with no group routing at all. If a group doesn't appear to be working, check the numbering first.
Controlling Order Within a Set
Because the questions in a statement must be consecutive, use dot syntax when you need a set to play in a non-sequential order. Q6.4.5 defines a set containing Q6, Q4, and Q5, shown in that order:
[group Q6.4.5 and Q7.9.8 max 1]
This lets you control order within a set while still satisfying the consecutive-numbering requirement across the statement.
Max Qualifier
If respondents should only see some—not all—of the questions or sets, add a max qualifier. In this example, respondents see only one randomly selected question:
[group Q1 and Q2 and Q3 max 1]
In this example, respondents are assigned to two of the three listed sets:
[group Q1-3 and Q4-6 and Q7-9 max 2]
If all respondents should see all questions in the group, the max qualifier is not needed.
Advanced Grouping: Balance
Add the balance keyword to ensure group assignment is balanced not only at the total level but also within each defined segment, based on prior survey answers and/or demographic traits.
Balance on Demographics
Balance exposure groups based on demographic traits such as gender or age.
Balance by gender:
[Group Q2-4 and Q5-7 and Q8-10 balance gender = "f", gender = "m" max 1]
Balance by age:
[Group Q2-4 and Q5-7 and Q8-10 balance age>=18 and age<=25, age>=26 and age<=41 max 1]
Commas separate balance segments; and joins conditions within a single segment.
⚠️ Note: Balancing on demographics ensures each node is balanced on that trait's distribution within the survey. If you need gender balanced overall across the total sample, apply quotas from the Target Market page.
Balance on Questions and Answers
You can also balance by any questions or answers that precede the groups.
Example: ensure equal distribution for Q5A8, Q5A9, Q4A2 among groups:
[Group Q6-9 and Q10-13 and Q14-17 balance Q5A8, Q5A9, Q4A2]
How Balance Handles Everyone Else
Respondents who match none of the segments you list are not excluded. A residual catch-all segment is created automatically, and those respondents are assigned and balanced among themselves.
💡 Tip: Keep the number of balance segments manageable—40 or fewer, or roughly your sample size divided by 10. Too many segments leaves too few respondents in each one for balancing to be meaningful.
Group Assignment
By default, Group Logic uses the least-fill method—respondents are sent to the group with the fewest completed respondents at that point in fielding, with ties broken at random. This means groups fulfill evenly over the course of fielding. No extra syntax is needed, but you can explicitly add leastfill to the logic if desired.
Least-fill also balances by position, not just total exposure: each set is balanced across each sequential position in the flow. This matters most in sequential monadic designs, where order effects can bias results.
To use purely random assignment instead, add randfill:
[group Q1-3 and Q4-6 and Q7-9 randfill]
When randfill is used, respondents are randomly assigned without regard for how many others have already been assigned to each node. This works well when there's no max limit, but risks uneven fulfillment when a max restriction is in place.
⚠️ Note: Do not use
randfillwith balance—randfill overrides the least-fill assignment that balance relies on to achieve even fulfillment at the total and subgroup level.
⚠️ Note: Before any responses exist, there are no fill counts to compare, so assignment falls back to a random pick. A survey in preview—or in the first moments of fielding—can look more random than it will be across the full sample.
Nested Group Logic
Nested Group Logic is advanced aytm Logic that introduces randomization within a larger set of randomized questions—streamlining programming for complex concept testing and reducing bias in respondent data.
Example: [group (q2-3 then q4 and q5) and (q6-q7 then q8 and q9)]
Additional Rules and Behaviors
| Behavior | What to Know |
|---|---|
| Pre-questions can't be grouped | Every reference in a group statement must be a survey question (Q). A statement that references a pre-question (PQ) is rejected. |
| Hidden sets are skipped | If every question in a set is blocked for a respondent (for example by [hide] logic), that set is passed over and another is selected, until the max is reached or no sets remain. |
| Range size limit | A single range cannot span 100 or more questions. |
| Multiple groups per survey | A survey can contain several independent group statements. Each is evaluated separately, and each must satisfy the numbering rules on its own. |
| No max means no limit | Omitting the max qualifier is equivalent to an unlimited max—respondents see every set in the group. |
| Errors are silent | Invalid statements are discarded without a warning. Always test group routing in preview before fielding. |
Learn more in the Lighthouse Academy course, Group Logic and Smart Loops!