The Basics
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 simply randomize a few questions.
Group logic must be entered either before the grouped section or into the first question within the group. A single logic statement starting with [group...] sets the rules that determine how respondents are directed through the groups in your survey flow.
Single Questions
To randomize the order that 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 the first question in the group logic statement, they'll see those three questions in a random order. Once they complete all three, they proceed to the next available question. Randomization is generated individually for each respondent.
Question Sets
To randomize the order that 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 random order. Once respondents complete all questions in all three sets, they proceed to the next relevant question.
⚠️ Note: Question numbers must not overlap between sets or the logic will not work.
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 randomly 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]
⚠️ 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]
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. This typically means groups fulfill evenly (±5 respondents on average). No extra syntax is needed, but you can explicitly add leastfill to the logic if desired.
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.
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)]
Learn more in the Lighthouse Academy course, Group Logic and Smart Loops!