Previous Next

To open or use this sample form, go to the Design tab, scroll down to the Your forms and datasets section, and click + then Start new form; then enable Use a sample form as your starting point and choose Rosters: Two methods for repeated questions from the list. You can also click here to download the spreadsheet form definition.

This sample demonstrates two different methods for collecting household roster information, where the same questions are asked repeatedly in order to collect information about multiple household members. One method simply repeats the same questions using a series of fields, showing only as many questions as are appropriate for the number of household members. The other method uses a repeat group to ask the same questions repeatedly, until the user ends the process. See Repeating fields for a full discussion of the different approaches to repeating questions.

The multiple-choice question in row 14 of the spreadsheet form definition allows the user to choose which of these two methods to use:

typenamelabelhint
select_one yesnouserepeatWould you like to use a repeating group for the household roster?A repeating group has a different UI and data structure.

If the user selects "No", then the first method of gathering data will be used; if the user selects "Yes", the second method will be used. The field's hint reminds users that repeat-group answers will be organized differently in exported data. This is how the first question, including its hint, will look:

If the user selects "No", then rows 16-34 describe how the survey will proceed. In this case, the user is first prompted to enter the number of family members in the respondent's household, then the survey proceeds to ask questions for exactly that number of people:

typenamelabelrelevance
integernumfamilyHow many family members live with you?${consent}=1 and ${userepeat}=0
textfam_name1What is the name of the first other family member who lives with you?${consent}=1 and ${userepeat}=0 and ${numfamily}>=1
textfam_name2What is the name of the second other family member who lives with you?${consent}=1 and ${userepeat}=0 and ${numfamily}>=2
select_one genderfam_gender1What is ${fam_name1}’s gender?${consent}=1 and ${userepeat}=0 and ${numfamily}>=1
select_one genderfam_gender2What is ${fam_name2}’s gender?${consent}=1 and ${userepeat}=0 and ${numfamily}>=2

Note the expressions in the relevance column for all of these fields: they all require "Yes" (which has a value of 1) to an earlier consent question and "No" (a value of 0) to the earlier "use repeat groups?" question. Additionally, some include conditions like ${numfamily}>=2 in order to only appear when appropriate; for example, if the respondent said that there was only one household member, then there should be no questions about a second household member.

If the user selects "Yes" to the multiple-choice question about using a repeating group, then rows 35-40 describe the questions that will follow:

typenamelabelrelevance
noterepeatintroNow I will ask you a few questions about each family member living with you.${consent}=1 and ${userepeat}=1
begin repeatfam_groupFamily member${consent}=1 and ${userepeat}=1
textfam_rg_nameWhat is his or her name?${consent}=1 and ${userepeat}=1
select_one genderfam_rg_genderWhat is his or her gender?${consent}=1 and ${userepeat}=1
integerfam_rg_ageWhat is his or her age?${consent}=1 and ${userepeat}=1
end repeatfam_group  

Before this set of questions is asked – or asked again – a pop-up window will ask if the user wishes to add (another) family member, using the label given in the begin repeat row:

As long as the user clicks Add Group, he or she can keep entering details for additional household members. As soon as he or she clicks Do Not Add, the survey continues (or, in this case, ends, since there are no additional questions).

See the next sample form for an example of a third, hybrid method in which a repeat group is used, but the group is repeated a fixed number of times. And do see the full discussion in Repeating fields if you haven't already.

Previous Next