How to program conditional question that show a number of rows on a matrix question based on a previous question?


I’m running a family survey and I would like the form to display a matrix question based on a previous question.

For example: I’ll ask a question about the number of family members, let’s say 5.

Based on that I want to condition a matrix question that show 5 rows, so I can fill with 3 fields like, family member, age and gender.

This is how it should work, more or less.

Is this possible?.

Hi @hescalar,

You could do the same as shown in the image below:

In the survey tab of your xlsform:

In the choices tab of your xlsform:
Image 2

Data entry screen as seen in Enketo:

Reference xlsform:
Sample Household Form.xls (29.5 KB)

Have a great day!

1 Like

Thanks, I will try ASAP.

Would you mind to explain how I could do the same in the web form builder? I don’t have a deep background in programming or commands but as an economist I’m able to make simple tasks like this. However, I work with persons who wouldn’t be able to work on a xls, the only way would be in the web form builder.

I just tried this solution in a project I duplicated and when I look at the table or the reports nothing is showed after the number of persons,

Those are the columns where I should find the data but, as you can see, they are empty. The only data registered is the number of persons in the family.

Hi @hescalar,

Kindly please be informed that controlling a loop of the roster based on the previous response (question) is only possible through the xlsform and at the moment is not possible using the KoBoToolbox form builder user interface.

However, if you do not wish to control the roster based on the previous response (question) and would wish to have an unlimited loop for your roster you could do it as outlined in the support article here.

Regarding your other query on not being able to view the roster data in the server, please follow the instructions that has been discussed earlier:

Have a great day!

Thanks, I downloaded the table and was able to find the sheet where the responses went, anyway I identified one error.

The correlative numbers of the listed responses by case were wrong, it appears to repeat the number of position when they go any further than 3. (in this case the first family had 4 members and the last had 3).

Do you have any thoughts on this error?.

Thanks in advance.

Hello again,

I flagged a problem in my last post, anyone have thoughts on the issue?.

Thanks in advance.

Hi @hescalar,

Would you mind trying this in a new project to see if this happens again (i assume, it should be a typo error).

Have a great day!