Sample form - Choice filtering guide
 Share
The version of the browser you are using is no longer supported. Please upgrade to a supported browser.Dismiss

View only
 
ABCDEFGHIJKLMNOPQRSTUVWXYZ
1
typenamelabelhintdefaultappearanceconstraintconstraint messagerelevancedisabled
required
required message
read only
calculation
repeat_count
media:image
media:audio
media:video
choice_filternoteresponse_note
publishable
minimum_seconds
2
startstarttime
3
endendtime
4
deviceiddeviceid
5
subscriberidsubscriberid
6
simserialsimid
7
phonenumberdevicephonenum
8
usernameusername
9
calculatedurationduration()
10
noteintro
<p><strong>Welcome to the SurveyCTO choice filter guide sample form!</strong><br /><br />This sample form is a companion to this guide to choice filtering:</p>
<p>&nbsp;</p>
<p><a title="Guide to choice filtering" href="https://support.surveycto.com/hc/en-us/articles/360033126194-Guide-to-choice-filters" target="_blank">Guide to choice filtering</a></p>
<p>&nbsp;</p>
<p>The examples here are numbered the same as in this guide. Feel free to copy and edit these expressions to suit your own requirements. Note that the examples you don't see in this sample form are discussed in part 3 of this guide.</p>
introno
11
begin groupg_example_1Example 1: Seasons
12
select_one seasonseasonWhat season is the next season?yes
13
select_multiple crops
crops
What crops will you grow next season?
yes
filter = ${season}
14
end groupg_example_1
15
begin groupg_example_3
Example 3: Filter out prior selections in a select_one field
16
select_multiple crops2
crops_home
Which crops do you grow at home?
If you choose "Refuse", you'll skip the second field in this example
not(selected(., '96') and count-selected(.) > 1)
You cannot select "Refuse" with other answers.
yes
17
select_multiple crops2
crops_market
Of these remaining crops that you don't grow at home, do you buy any of them at the market?
not(selected(., '96') and count-selected(.) > 1)
You cannot select "Refuse" with other answers.
count-selected(${crops_home}) < 7 and not(selected(${crops_home}, '96'))
yes
not(selected(${crops_home}, filter))
18
end groupg_example_3
19
begin groupg_example_6
Example 6: Repeated fields as choice filter criteria
20
begin repeat
g_example_6_roster
Rosterfield-listindex() <= 5
21
textnameName of household member.
Only 5 household members can be captured
yes
22
integerageAge of household memberEnter between 0 and 120. >= 0 and .<=120
Enter between 0 and 120
yes
23
calculatecount_if_18_plus
Returns 1 if the household member is 18, and 0 if not.
if(${age} >= 18, 1, 0)
24
calculate
include_in_not_18list
Includes those who are not 18 in a list to display later.
if(${age} < 18, concat(${name}, ' ','(age ',${age},')',linebreak()), '')
25
end repeat
g_example_6_roster
26
calculatesum_if_18_plus
Sums the values in "count_if_18_plus".
sum(${count_if_18_plus})
27
calculatelist_if_not_18
A list of those who are not 18 to display.
join('', ${include_in_not_18list})
28
noteexample_6_warning
Note: No household members 18 or older were recorded.

${list_if_not_18}
Go back and revise so that at least one household member is 18 or older so that you can see this example working in practice.
${sum_if_18_plus} < 1
no
29
calculatename_1_calc
Collects the value from the 1st instance of "name".
indexed-repeat(${name}, ${g_example_6_roster}, 1)
30
calculatename_2_calc
Collects the value from the 2nd instance of "name".
indexed-repeat(${name}, ${g_example_6_roster}, 2)
31
calculatename_3_calc
Collects the value from the 3rd instance of "name".
indexed-repeat(${name}, ${g_example_6_roster}, 3)
32
calculatename_4_calc
Collects the value from the 4th instance of "name".
indexed-repeat(${name}, ${g_example_6_roster}, 4)
33
calculatename_5_calc
Collects the value from the 5th instance of "name".
indexed-repeat(${name}, ${g_example_6_roster}, 5)
34
calculateage_1_calc
Collects the value from the 1st instance of "age".
indexed-repeat(${age}, ${g_example_6_roster}, 1)
35
calculateage_2_calc
Collects the value from the 2nd instance of "age".
indexed-repeat(${age}, ${g_example_6_roster}, 2)
36
calculateage_3_calc
Collects the value from the 3rd instance of "age".
indexed-repeat(${age}, ${g_example_6_roster}, 3)
37
calculateage_4_calc
Collects the value from the 4th instance of "age".
indexed-repeat(${age}, ${g_example_6_roster}, 4)
38
calculateage_5_calc
Collects the value from the 5th instance of "age".
indexed-repeat(${age}, ${g_example_6_roster}, 5)
39
select_one example_5_select
example_6_select
Please choose a respondent, 18 and older.

The following household members are not included:

${list_if_not_18}
${sum_if_18_plus} > 0
yes
indexed-repeat(${age}, ${g_example_6_roster}, filter) >= 18
40
end groupg_example_6
41
begin groupg_example_8Example 8: Static choice filters
42
select_one yesno_refuse
example_8_question
Do you see that in practice, "Refuse" gets filtered out?
Test this field with the form design visible
yesfilter != 0
43
end groupg_example_8
44
begin groupg_example_9
Example 9: Cross-category cascading select filtering
45
select_one orgorgChoose the organization.yes
46
calculatecalc_org_label
jr:choice-name(${org}, '${org}')
47
select_one projectproject
Choose the project associated with ${calc_org_label}.
Keep in mind that one project can fall under more than one organization
yes
regex(filter, concat('.*', ${org}, '.*'))
48
end groupg_example_9
49
begin groupg_example_10Example 10: Multiple filter columns
50
calculatecalc_randomonce(random())
51
select_one yesno_refuse
adultAre you 16 or older?yesfilter != 0
52
select_multiple health_attitudes
health_attitudes
Please check all the items that apply to you.
yes
filter = ${adult} and randomization = int(${calc_random}*2)+1
53
end groupg_example_10
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
Loading...