How to Use Repeat Groups in XLSForm
A repeat group in XLSForm collects the same set of questions multiple times — once per item in a list — by wrapping those questions between begin repeat and end repeat rows. It is how you record a household roster, a list of crops, or every child in a family without knowing the count in advance.
Repeat groups solve a problem paper forms handle badly: a variable number of items. Instead of printing ten blank "household member" blocks and hoping that is enough, a repeat group lets the enumerator add exactly as many entries as the interview needs.
How do you create a repeat group?
Add a begin repeat row, put the repeating questions beneath it, and close with an end repeat row. The name on begin repeat and end repeat should match.
| type | name | label |
|---|---|---|
| begin repeat | member | Household member |
| text | member_name | Name of household member |
| integer | member_age | Age |
| select_one sex | member_sex | Sex |
| end repeat | member |
During collection, ODK asks for the first member's name, age, and sex, then offers to add another member, repeating the block as many times as needed.
How do you control the number of repetitions?
Add a repeat_count column to set how many times the block repeats. You can fix it to a number, or — more usefully — drive it from an earlier answer:
| type | name | label | repeat_count |
|---|---|---|---|
| integer | hh_size | How many people live here? | |
| begin repeat | member | Household member | ${hh_size} |
| text | member_name | Name of household member | |
| integer | member_age | Age | |
| end repeat | member |
Here the form first asks household size, then automatically creates exactly that many member blocks. This guarantees the roster length matches the reported size.
Leave repeat_count blank to let the enumerator add and remove entries freely. Use it only when an earlier answer should fix the count — otherwise you prevent legitimate corrections in the field.
How do you reference answers inside a repeat?
Two functions let you use repeated data elsewhere in the form:
count(${member})— the number of entries collected in the repeat.indexed-repeat(${member_age}, ${member}, 1)— the value from a specific repetition (here, the first member's age).
| type | name | label | calculation |
|---|---|---|---|
| calculate | total_members | count(${member}) | |
| note | summary | You recorded ${total_members} household members. |
Inside the repeat, you reference sibling answers normally with ${member_name} — each repetition sees its own values.
You cannot put a repeat group inside a constraint that spans the whole list directly. To validate across repetitions — for example, "exactly one head of household" — use a calculate with count() and a constraint or note that checks the calculated total.
Why repeat groups matter in the field
Repeat groups make rosters accurate and complete. They capture the real number of household members, livestock, or visits rather than forcing data into a fixed number of slots, and they keep each item's answers neatly linked. Exported data lands in a separate, tidy table per repeat — clean to analyze. For complex rosters, build them faster with LooprAI, which generates the begin/end repeat structure and count logic from a plain-English description.
If the roster must persist across forms or be updated during later visits, use the ODK Entities and longitudinal workflow instead of keeping every record inside one submission.
Build my first form freeNext: How to Add Skip Logic in XLSForm →
Frequently Asked Questions
What is a repeat group in XLSForm?
A repeat group is a block of questions wrapped between begin repeat and end repeat rows that collects the same questions multiple times, once per item in a list. It is used for rosters such as household members, crops, or visits where the number of items varies.
How do I set the number of repetitions in XLSForm?
Add a repeat_count column to the begin repeat row. Set it to a fixed number, or reference an earlier answer like ${hh_size} so the form creates exactly that many repetitions automatically. Leave it blank to let the enumerator add entries freely.
How do I count entries in an XLSForm repeat group?
Use the count() function with the repeat name, for example count(${member}). Place it in a calculate question to store the total number of entries, then display or validate it elsewhere in the form.
How do I reference a specific answer inside a repeat group?
Use the indexed-repeat() function. For example, indexed-repeat(${member_age}, ${member}, 1) returns the age from the first repetition. Inside the repeat itself, reference sibling answers normally with ${question_name}.
How is repeat group data exported?
Each repeat group is exported as its own table, linked to the main submission by an ID. So a household roster produces a separate members table with one row per member, which keeps repeating data tidy and easy to analyze.
No Credit Card Required
Build the form first. Add hosting when you need it.
Start free with LooprAI, then deploy a managed ODK Central server or run DataSnap checks when your project is ready.
Hundreds of users trust SurveyLoopr