How to tailor question sets based on combination of responses submitted in XLS Forms

Background:

My form employs skip logic to tailor the question set depending on the age of the person entered. For example, if a person is 51 years old, they see the group of questions for 50-60 year olds. Other key info:

  • All questions have the answers YES, NO, DON'T KNOW.
  • Field-list appearance is applied to each question group to achieve that all relevant questions for that person, based on his age, appear on the same screen.

Test form attached here. test.xlsx (81.3 KB)

Problem:

How can I achieve the following three requirements using XLS Forms (e.g. Relevant column?)?

Scenario: Age of person = 50. The question set relevant for this age group (50-60 year olds) is displayed.

  1. If the first question = YES, then if 5 consecutive NOs are entered at any point in the question set, all questions following the one with the 5th NO are removed (skipped)

  2. If the first question = NO, then if 4 consecutive NOs are entered following this first NO (total of 5 NOs consecutively), then the rest of the questions for that age group are skipped, and instead the questions from the previous age group (40-50 year olds) must be answered.

  3. Even though the full question set appears on a single screen (using groups & field-list appearance), all questions must be answered in the order they appear (an answer to a question is only allowed if the previous question has already been answered).

What app or server are you using and on what device and operating system?

Using XLS Forms on ODK Collect v1.22.4 connected to ODK Aggregate v2.0.3

Thank you very much for your help.

Hi @uprojects
welcome to the forum! Please introduce yourself here!

I think you can try this sample
test.xlsx (17.0 KB)
which should fix your problem with displaying an appropriate group an the last problem with requiring answering questions in the order they are placed.

When it comes to case 1 and 2 I think you should be able to do something like that using relevant after analyzing my sample.

Thank you, I have understood the solution for problem 3. Regarding problems 1 and 2:

  1. If the first question = YES, then if 5 consecutive NOs are entered at any point in the question set, all questions following the one with the 5th NO are removed (skipped)

  2. If the first question = NO, then if 4 consecutive NOs are entered following this first NO (total of 5 NOs consecutively), then the rest of the questions for that age group are skipped, and instead the questions from the previous age group (40-50 year olds) must be answered.

How could I solve these? I've searched in various XLSform documentation online and several tutorials, and perhaps the coalesce function could be used, but there's not enough instruction there to help me understand how to apply it for these problems.

Can you provide an example or any instruction (or even links I could refer to) for how I may solve this? my form has approx 200 questions split into 6 age groups, so I need a solution that is "scalable" in that sense.

Thank you very much.

Try this:
test.xlsx (17.1 KB)
there is only a sample for question 7

it would be difficult...

Your best bet might be to consider putting all these questions in a repeat group, and having a calculation to count the number of "NO's" in the last 5 iterations, and stop the repeat if count=5; ie all last 5 were "No".

You can probably also handle this similar to above once you have this count of the last 5 responses: if the count=5, and number of iterations=5 (ie case 2), then you'll end the repeat group (as above), and you can choose to show something else afterwards as appropriate.