ODK ERROR: INDEXED-REPEAT ERROR
ODK common errors and solutions

Error evaluating field ‘[field_name]’: The problem was located in [calculate/relevance/constraint] expression for field_name. This field is repeated: /form_id/repeat_group_instance[1]/repeated_field[1] /form_id/repeat_group_instance[2]/repeated_field[1]. You may need to use the indexed-repeat() function to specify which value you want.


Have you received this error while using ODK? SurveyCTO is here to help!

What does this error mean?

This is commonly known as an “indexed-repeat error.” It occurs when a field that is inside a repeat group is directly referenced from outside that repeat group. The error message is indicating that the repeated field that has been referenced from outside the repeat group is the field named repeated_field and the field that contains the expression where the repeated field has been referenced is the field named field_name.

For example, assume I have a household roster and inside this household roster, I have a field called ‘age’ where I ask the age of a different household member in each instance of the repeat group. At a later point in my form, outside this household roster repeat group, suppose I have a relevance expression for a question like the following: ${age} > 18.

I have directly referenced the ‘age’ field from outside the repeat group, but the ‘age’ field is a repeated field, which means that instead of a single age field, there are multiple copies of the age field, one for each instance of the repeat group. So I will get this error message because the form does not know which instance of ‘age’ I want to refer to in that relevance expression.


How do I fix this error?

In order to tell the form which instance of the ‘age’ field it should reference in the relevance expression, you need to enclose the ‘age’ field inside the indexed-repeat() function.

  1. Identify the repeated field that is causing the error.

    In the indexed-repeat() error message, the name of this field is provided at the end of the portion that says:

    This field is repeated: /form_id/repeat_group_instance[1]/repeated_field[1]

    Look at the bolded part (repeated_field). That is the name of the field inside your repeat group that you have referenced outside the repeat group.

  2. Open your XLSForm definition in Excel and use Ctrl+F to search for all references to the repeated_field.

  3. Anywhere in your form that you find you have referenced this field directly outside its repeat group, enclose the field inside the indexed-repeat() function to specify which copy of the field you are referencing.

    The syntax of the indexed-repeat() function is the following:

    indexed-repeat(repeated_field, repeat_group_name, instance_number)

    For example, let’s say that in my relevance expression where I referenced the ‘age’ field, I meant for the expression to check the age entered in the third instance of my household roster (since there is more than one age – one for each household member – I had to have some specific member’s age in mind when I wrote that expression). And let’s say that my household roster repeat group was called ‘member_roster’. To correctly reference the third copy of ‘age’, I should change my relevance expression to:

    indexed-repeat(${age}, ${member_roster}, 3) < 18

    Once I make this fix, I will no longer get the indexed-repeat() error. Of course, the ‘age’ and relevance expression example is just that – an example. But you can apply the same logic and approach to other repeated fields in other types of expressions (such as constraint expressions, calculate expressions, choice filter expressions) anywhere in your form.

  4. More information

    The concept of repeated fields, indexed-repeat(), and indexed-repeat() errors is a complex one. Check out this article for more guidance, which is accessible to anyone with a SurveyCTO account (sign up for a free trial here).


Pro tip:

Perhaps you don’t specifically want any instance of ‘age’. Maybe you want a field to be relevant if any single household member is older than 18, for example. How do you do that? Create a calculate field inside the repeat group with the expression, “if(${age} > 18, 1, 0)”. Let’s name this field “older_than_18”. Give any field (or group of fields) that should appear only when there’s a household member older than 18, the relevance, “sum(${older_than_18}) > 0”.


We hope you found this helpful. Feel free to browse through our other ODK error guides. To try SurveyCTO for yourself, and see all the improvements we made to ODK, you can sign up for a free 15-day trial. We offer 24x7 support from research experts, customizable form designs, smart data quality controls, and best-in-class data security.

More solutions to ODK errors

SurveyCTO vs ODK

Sign up for a free SurveyCTO trial

Close Menu