Rosters: Choosing among earlier entries
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: Choosing among earlier entries (variation 1) or Rosters: Choosing among earlier entries (variation 2) from the list. You can also click here (variation 1) or click here (variation 2) to download the spreadsheet form definition.
This sample has two variations, both of which populate the possible answers to a multiple-choice question with the household member names entered earlier in the survey. In both, the choice lists are on the choices sheet of the spreadsheet form definition as follows:
list_name | value | label | filter |
hhmember | 1 | ${fam_name1} | 1 |
hhmember | 2 | ${fam_name2} | 2 |
hhmember | 3 | ${fam_name3} | 3 |
hhmember | 4 | ${fam_name4} | 4 |
hhmember | 5 | ${fam_name5} | 5 |
The labels for the choices come from the names entered earlier, and the filter column is used to filter the list so that only the appropriate number of names are shown (i.e., so that blank names don't appear when there are fewer than five household members).
The choices are shown (and filtered) for the "worker_hhmember" field on the survey sheet:
type | name | label | choice_filter |
select_one hhmember | worker_hhmember | Which household member? | ${numfamily}>=filter |
The difference in the two variations of this sample form is as follows: variation one prompts for household member names in a series of fields named fam_name1, fam_name2, etc.; variation two uses a repeat group to prompt for household member names, then has to pull the names out of the repeat group using a series of calculate fields named fam_name1, fam_name2, etc. These calculate fields are defined as follows:
type | name | calculation |
calculate | fam_name1 | indexed-repeat(${fam_rg_name}, ${fam_group}, 1) |
calculate | fam_name2 | indexed-repeat(${fam_rg_name}, ${fam_group}, 2) |
calculate | fam_name3 | indexed-repeat(${fam_rg_name}, ${fam_group}, 3) |
calculate | fam_name4 | indexed-repeat(${fam_rg_name}, ${fam_group}, 4) |
calculate | fam_name5 | indexed-repeat(${fam_rg_name}, ${fam_group}, 5) |
These calculate fields use the indexed-repeat() function (see Using expressions in your forms) to pull the names from the earlier repeat group and put them into individual fields that can be referenced in the labels on the choices sheet.