Repeat questions using different questions outside repeat

What is the problem? Please be detailed.
I have 10 different questions with (YES-NO), i want to create a repeat group of 5 questions by using the YES of the above 10 questions. if there is a yes then run the repeat group by the same index. suppose if there are first two question has NO and third has YES then skip the first two index of repeat group and use the third index to run the repeat group.

What ODK tool and version are you using? And on what device and operating system version?
i am using xls form and latest version. i want to run it on my tablet with android.

What steps can we take to reproduce the problem?

What you have you tried to fix the problem?
I am just trying solve it by my own but did not reach to a certain point.

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

hi @Dp_Lhr2000,
please can you share a sample file sample_xlsform of your work here and we can help you solve the problem, i am looking at it in two ways so if i have a clear picture of what you are trying to do we can best help you solve it.

tmp_1.xlsx (13.7 KB)
Here you can see my file for better understanding.

1 Like

The only way I can think of is to make 10 select (yes/no) prompts and 10 groups (one for each yes/no prompt, with a skip logic to evaluate if a YES was selected), in each group you'd have your 5 prompts for person's gender etc. Looks like 50 prompts for just person details :frowning:

hi @Dp_Lhr2000
I have look at your sample file and I think you can first consider using multiple select for the first 10 question, thus you will be given a list of the names of the people where you have to select only those in the list who are available and then the repeat group questions will be asked to only those who are selected. this can be apply if you already have the names of the those people. see a sample file below to see if it will work for you. repeatgroup.xlsx (47.1 KB)

Note;

  1. if you want only the repeat to apply to only 5 people then you can let me show you how to select a maximum of 5 people from the list so that the repeat group will be apply to only the 5 selected persons.

  2. if you do not have the list of the people and you have to enter them before you can have the list to find out those who are available you can let me show you how to do that one too.

Thanks
fabla2020@gmail.com

1 Like

Thanks @Sam_Shaba . but this way is not feasible for larger set of questions. As i have already this process in my mind.
Thanks again

Thanks @Fabla for your brief response.

1 Like

@Fabla many thanks for sharing this xls.Can you please explain two calculations

if(position(..)-1 < count-selected(${members}), selected-at(${members}, position(..)-1), -1)

and

jr:choice-name(${mem_post}, '${members}')

Thanks in advance.

Hi @ARIF_AZAD_KHAN

for the first calculation

the above calculation is to select the one of the listed options, thus the position for each option should remain the same position in the subsequent questions they are loop to.

Below are the explanation of the calculations

NOTE; members is the field name of the multiple choice field.

  1. the if condition determines which option is choose in the multiple choice.

  2. position(...), is the position of the option selected

  3. -1, this holds the position of any option number in the multiple choice.

  4. position(...)-1 holds the same position from the multiple choice, that is if
    1=Khan
    2=Fabla
    3=Abdul
    4=Fauzy
    when you select 2 in the multiple choice you should be seeing 2 for Fabla when you loop it in subsequent questions.

  5. count-selected(${members}), this count the total number of options selected in the multiple choice.

  6. selected-at(${members}), position(...) -1) this is the field of the multiple choice and the position which is selected. so under members, which option is selected. so if option 4 is selected under members it will pick option 4 for the loop.

  7. if position(...)-1 is less than count-selected(${members}), it should use selected-at(${members}), position(...)-1) but if position(...) -1 is greater than count-selected(${members}) then it should use -1 (which holds the position of the option number)

Example; if 2 options are selected say 1 and 5, the count-selected(${members}) will be be 2, so for the first option selected which is 1, it is less than the total number of options selected, so the selected-at(${members}, position(...) -1) will be used. which is option 2. for the second option, which is 5, but 5 is greater than the total number of options selected (2) so it will pick the -1 that his holding the position of the option number.

for the second calculation
NOTE; mem_post is the field name for the calculated field of the position of the multiple choice.

this is use to get the label from the choice sheet. when you are making reference to a selected option in a previous question, if you have a question like; select all your direct relative among the list
1=Khan
2=Fabla
3=Abdul
4=Fauzy

if you select option 2 and 4 in the above question and there is a subsequent question like;

on xlsform
how old is ${members}?

on ODK Collect
This question will display as how old is 2 and how old is 4
unless you put the calculation above.

jr:choice-name will look into your multiple field (members) and pick the calculated position for the selected option from the multiple choice and display the label of the selected option.
so when you do this calculation, your next question will now look like.

on xlsform
how old is ${mem_post}?

on ODK Collect
This question will display as how old is Fabla and how old is Fauzy

I believe this explanation is clear for you to understand the calculations in the sample file.

Thank you.
fabla2020@gmail.com

1 Like

@Fabla Many many thanks. Your explanation is clear and easy to understand.

1 Like

A post was split to a new topic: How can I adjust follow-up values when values in repeats change?