The countChecked
function returns the number of items checked in a checkbox question.
Syntax
Simple
countChecked(Question ID)
Check Against Range
countChecked(Question ID, Option IDs)
Examples
Show follow up question if two or fewer selections
In the example below, if a respondent checks only one or two response options for question 7, then countChecked($Q7) <= 2
returns “true” (the condition is met) and the respondent sees question 7D.
Return number of items checked
You can also use the countChecked
function to return the number that were checked in a question. This could be helpful to display that number on screen.
In the example below, the follow-up question will display the number of options that were selected for question 7.
Note: The above example uses a Perl code block to allow the countChecked
function to render the number checked on screen. Without this it would render the text on screen rather than evaluating the function. Perl code blocks are denoted using the [* and *] syntax. For more information, see Piping with Perl.
Check against range
countChecked
also allows programmers to specify an option or range of options to be counted. Where countChecked($Q1)
will return the number of options checked in Q1, countChecked($Q1,1..5)
will return the number of options among the specified codes 1,2,3,4,5 that are checked. Consider the following example:
QFLAVORS employs a cvalue
where the countChecked
function will return a value of 1, 2, or 3, because that is the range of options specified to be counted at Q1. Checking option 4 at Q1 will have no impact at QFLAVORS.
Comments
0 comments
Please sign in to leave a comment.