Difference between revisions of "SurveyCTO Conditional Filtering"

Jump to: navigation, search
Tag: New redirect
 
(6 intermediate revisions by 3 users not shown)
Line 1: Line 1:
== Best Practice ==
#REDIRECT[[SurveyCTO Choice Lists#Conditional Filtering]]
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 [[SurveyCTO Dynamically Populated Choice Lists|Dynamically Populated Choice Lists]] example by allowing us to focus on particular parameters during follow up questions.
There are countless ways in which '''SurveyCTO Conditional Filtering''' can be applied in practice. More examples would be when preparing a [[SurveyCTO Choice Lists|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 [[SurveyCTO Conditional Filtering | filters]] can be applied to any parameter recorded inside the initial repeat group.


There countless ways in which this 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 [[SurveyCTO Dynamically Populated Choice Lists | 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 [[SurveyCTO Dynamically Populated Choice Lists|Dynamically Populated Choice Lists]] example by allowing us to focus on particular parameters during follow-up questions.


== Coding Example ==  
== Coding Example ==  
[LINK Here is a code example]. There are notes in the ’label’ column of calculate fields of the SurveyCTO explaining what each field does.  
[https://drive.google.com/open?id=1fT42GnXL8yV85rMO5vwwZSi_54lBmZ3CkKrPvwkUTyw 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:
This is achieved through '''3 steps''':


* 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 is TRUE, blank if FALSE.
#'''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.
#'''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'''.
#'''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.


* 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'''.
== Related Pages ==
 
[[Special:WhatLinksHere/SurveyCTO_Conditional_Flitering|Click here for pages that link to this topic]].
* 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.
 
== Back to Parent ==
This article is part of the topic [[SurveyCTO Coding Practices]]


[[Category: SurveyCTO Coding Practices ]]
[[Category: SurveyCTO Coding Practices ]]

Latest revision as of 23:36, 20 July 2023

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.