Repeat question based in a condition or relevance

1. What is the problem? Be very detailed.
I have a group of repeated questions about Education. This questions must be displayed if the question about age is greater than 5 or equals (age >= 5).
I tryed use relevant but I got this error when I try to convert de XLS Form: "${seccao1}[1]/membro_demografia[1]/s1p5[1];${seccao1}[1]/membro_demografia[2]/s1p5[1]
You may need to use the indexed-repeat() function to specify which value you want."
2. What app or server are you using and on what device and operating system? Include version numbers.
Server: Google Drive
Device: Samsung Galaxy Tab 201

3. What you have you tried to fix the problem?
I tryed use relevant (age >= 5)

4. What steps can we take to reproduce the problem?
Download the file

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Hi @Ayod_El_Modai_Arune

I think the issue is that you are trying to reference a variable ${s1p5} which is in a repeat group.
As you reference it from outside that group, you need to specify which iterations should be considered.

One approach is to interview one respondent at the time (instead of doing it by section). This way you would have a single repeat for the whole questionnaire.

The other approach is to check the age of each respondent. You can do it by inverting the order of group and repeat of seccao2 and using the position(..) variable to cycle with indexed-repeat through the age of respondents. Please see sample file attached censo_af_form_ine_grpoc_1709_ix_am.xlsx (116.2 KB) .

I hope this helps!




You gave me the solutions!
I used the the second approach that you insert in this file.

Thanks a lot!

1 Like


Glad it worked :slight_smile:
All the best with your project!


1 Like

Hi @Andrea_Martin and @Ayod_El_Modai_Arune,

Thank you for creating this topic.

I need your support with a similar problem I am facing. Any help would be very much appreciate it :slight_smile:

In my survey, I first ask the age of each member of the household. After a number of questions I want to ask questions regarding their tobacco and alcohol consumption but I want these to be repeated only for individuals who are 20+ years. I have then created a repeated question group for each individual in the household but I am having difficulties in making it appear only people who are 20+. Please see attached the xls form for this **(ODK_example.xls) ODK_example.xlsx (12.3 KB)

I have then tried using the solution suggested by Andrea (see attached ODK_example 2) but I get the following error: ODK_example_2.xlsx (12.7 KB)

">> Something broke the parser. See above for a hint.
Error evaluating field '_8_1_BP_and_chol' (${function_repeat_hh_mem_past_diagnosis_adults}[1]/_8_1_BP_and_chol[1]): The problem was located in Condition expression for ${_8_1_BP_and_chol}
XPath evaluation: type mismatch
indexed-repeat(): parameter 2 must be a parent of the field in parameter 1
Caused by: org.javarosa.xpath.XPathTypeMismatchException: The problem was located in Condition expression for ${_8_1_BP_and_chol}
XPath evaluation: type mismatch
indexed-repeat(): parameter 2 must be a parent of the field in parameter 1
... 10 more"

Do you know why this is happening?

Thank you so much in advance for your help :slight_smile:



Hi @Olimpia,

It look the compiling errors can be fixed by correcting the following typos:

  • in the label of ${hh8_7_tobaccol}: name_mem_4 should be name_mem_3
  • in the relevant expression for ${_8_1_BP_and_chol}: ${function_repeat_number_details} should be ${function_repeat_hh_mem_details}
  • add an age_mem variable

See attached file: (ODK_example_2_AM.xlsx (12.9 KB) )

A couple of unsolicited suggestions:
a) you might want to use current name including both clan and second name, as some second names could be repeated within the same hh;
b) the use of repeat seems too convoluted (as if trying to replicate the paper forms which are split in pages). In my opinion, one of the beauties/advantages of CAPI is that it allows to conduct more natural interviews, by programming skips and relevant conditions. I would suggest you consider streamlining your questionnaire by collecting information about each of the hh members in sequence. Not only the questionnaire would likely be faster to administer, it will also be easier to program. See this example (ODK_example_2_alt_AM.xlsx (12.2 KB) )

Hope this helps!


1 Like

Hi @Andrea_Martin,

Thank you so much for your answer and suggestions, the files works perfectly now.

I found the unsolicited suggestions very interesting but I have two questions:

  1. From what I understand, you use one single repeat for the whole survey. However, I have some multiple answer questions (e.g. 3.4 Who is the household head?) where I want the individual to select one of the names given (see xls form attached). How can I address this with a less convoluted repeat form?
    I have tried redoing what is in your example but then the multiple choices remain blank.
    Begin_repeat_test.xlsx (18.7 KB)

  2. When I export the collected data into a csv form, the questions that are under a repeat function appear to have the following answer "uuid:0b78d68e-cadd-4abe-a558-32484237700d/function_repeat_hh_mem_details". I have attached the csv document with two example answers. Do you know how I can have the answer for each individual as a row?
    For example if I have two people in the household: Olimpia and Andrea, I want one row with Olimpia's details (age, tribe, religion etc) and one row with Andrea's details (age, tribe, religion..) which can be matched by a unique household id.
    Day1_HH_survey.csv (8.1 KB)

Any help would be very appreciate it.

All the best,


Hi @Olimpia ,

Please find attached (ODK_example_2_alt_AM.xlsx (12.3 KB) ) a possible "streamlined" version of the questionnaire.
Main suggested modifications include:

  • The first person of the roster must be the HH head. It should be fairly easy to identify and it does not require other information to be answered (see also Repeat a question only if specific question is selected for the person on the first position)
  • Allow the user to register as many hh members as needed (while if you force the respondent to tell you in advance the number they might forget someone and later it might be more complicated to add)
  • Use answers in the roster to calculate the information you need (e.g. hh size is a count of the repeat loops)
  • Key 'yes' and 'no' as 1 and 0, this way (when needed) you can easily count how many hh member meet a certain criteria in a loop by simply summing that field
  • the roster usually comes first in the questionnaire and details about the house in general (e.g. WASH) are asked later, once the numerator has already familiarized with the respondents

For the export part, are using ODK Aggregate export feature?
I would suggest you try using ODK briefcase instead. Once you export the submissions, you will have separate csv files for each repeat group, which you can merge using the parent_key field.

I hope this helps!