SurveyCTO Conditional Filtering

Jump to: navigation, search

There are countless ways in which SurveyCTO Conditional Filtering can be applied in practice. More examples would be when preparing a choice list after a crop-level repeat group of crops that were irrigated and/or sold, or filtering household members who earn income. Remember that the filters can be applied to any parameter recorded inside the initial repeat group.

Read First

  • Sometimes we want to restrict the available choices from dynamically populated choice lists.
  • In this example we use a household roster, where we want follow-up questions to only allow choices of Q1) males under 20, Q2) females over 20. The key is that we are able to ’increase’ the level of the fields from a repeat group up a level and combine everything there using the join() function.
  • This example builds upon the Dynamically Populated Choice Lists example by allowing us to focus on particular parameters during follow-up questions.

Coding Example

Here is a code example. There are notes in the ’label’ column of calculate fields of the SurveyCTO explaining what each field does.

This is achieved through 3 steps:

  1. Set up a calculate field inside the repeat group for each condition that you want to filter later (lines 17-20). The field should yield the repeat number if TRUE, blank if FALSE.
  2. Add a set of joining calculate fields outside of the repeat group (lines 31-34). These result in a list of the repeat group calculate field results that adhere to the earlier condition, which are stored in select_multiple format, e.g. 1 4 5.
  3. We then leverage this field by using it as the base for the filter in the questions on lines 35 and 36. Note the relevance fields only show these questions if at least 1 instance of the condition is TRUE.

Related Pages

Click here for pages that link to this topic.