Indexed-repeat problem with question types other then calculate


If an indexed-repeat calculation with a type other then calculate is used, a wrong result is given in Enketo Preview and an error on deploy.

We want to use the age of the head of household (first person) to check against age of biological son/ daughter (minimum age difference = 12 years). Both persons are entered inside the repeat group

Steps to Reproduce

  1. See attached example 02, with type integer (or text). Import, preview and deploy (error)
    IndexedRepeat 02 GR CALC.xlsx (40.5 KB)
    2 See attached example 01, with type calculate. Import and preview and deploy (ok)
    IndexedRepeat 01 GR INTEGER.xlsx (40.5 KB)

Expected behavior

Behaviour should be the same, independent of question type.

Actual behavior

For example 01,: In Preview actual repeat case referenced instead of person 01 (head). and error on deployment.

Same error at

Additional details

Behaviour in integer example (01) is the same,

  • if there is no group inside the repeat
  • if type is text…
    If calculate type, all is fine.

We use OCHA Server and XLSForm.

Behaviour is different (ok) if the calculation is put after the repeat, see example 03
IndexedRepeat 03 GR INTEGER.xlsx (40.5 KB)
Blue is inside the repeat (still wrong).

Hi @wroos,

Kindly please be informed that Indexed-repeat is a function that allows you to get information from a specific iteration of a repeat group and use in either in another area of the form or in another repeat group (but not within the same repeat group).

Indexed-repeat is not used within the same repeat group as you have used. Instead try out using Indexed-repeat as follows:

In the survey tab of your xlsfrom:

Data entry screen as seen in Enketo:

Reference xlsform:
IndexedRepeat 02 GR CALC_Edited.xlsx (26.6 KB)

Have a great day!

Dear @Kal_Lam,
thanks for your answer. (Where can I find this restriction in the documentation?)
Would you mind to test the first xls example, please. With calculate type it works fine inside the repeat, in KoBoCollect as well as in Enketo Preview, and can be deployed (But NOT if you use it with another type, like integer.)

We use it (calculate type) to check age differences directly in the loop, like IF relationship of this person to Head of Household is Child: PersonAge must be at least 12 years less than AgeHead, etc.
A solution outside the loop would need complicated moving back after the whole HH-Roster.

What could be another (userfriendly) solution for this? Would a calculate fire early enough for using the value (AgeHead) then inside the repeat, e.g. if we put it before or behind the repeat?
Kind regards

Hi @wroos,

We will be updating the repeat question support article soon. FYI, please be informed that we have already drafted the updates and will be making it public soon.

You should also find this discussion useful on the use of indexed-repeat function:

Have a great day!

IndexedRepeat 01 GR CALC.xlsx (40.5 KB)
We need to confirm, please, if we can use this? (KoBoCollect)

In case NOT, we would like to see another solution, please?
The 1st requirement is, to check age of current person against age of head (first person), based on relationship. Here is a more real example: HHRoster01.xlsx (17.1 KB)

A 2nd requirement is to show current person info in the repeat header.

Both is working FINE in KoBoCollect, but not in Preview Enketo. WHY??
Thanks in advance!

We meanwhile found another problem which may be related. See Missing update of Label with calculate reference in Repeat - Enketo (Preview))

Kind regards

Hi @wroos,

My advise would be avoid using indexed-repeat function within a repeat group from where you have to make a reference. i.e.

var 1
var 2
var 3                                                indexed-repeat

Try correcting it as follows:

var 1
var 2

var 3                                                indexed-repeat
var 4                                                indexed-repeat

Note: You could use indexed-repeat either outside the repeat or within the repeat as shown above, but should be referring to the repeat from the previous repeat (here either var 1 or var 2).

Have a great day!

Hello @Kai_lam,
thanks. I am really sorry, to continue the discussion.
But I do not understand, why we should not use it, as seems to work fine in KoBoCollect. Would you mind to deploy and have a look at this more real KoBoCollect example, please:
HHRoster01.xlsx (17.1 KB)
The 1st requirement is, to check age of current person against age of head (first person), based on relationship.
(A 2nd requirement is to show current person info in the repeat header.)

Could you give a changed version, please, how YOU would solve the 1st requirement? (Without having a too complex UI, if correction is needed. And with keeping the head inside the repeat). How would you reference the current HH member outside the repeat? Also keep in mind, please, that we have to do similar checks for other relationships to the head.

With calculate type (AgeHead) the example also seems to works well in Enketo Preview (but not if you change to other type, like integer, it changes behaviour in Enketo!)

Thanks again in advance!
I copy @Xiphware in, as he might know if there is a restriction in (ODK) Collect code, to use the indexed-repeat directly inside the (same) repeat (as in our XLS example