Get Counts uses the $_counter
and get
Perl methods to return the current number of Completed respondent records for a given question (or variable) option.
set list: DRINKS
1. Coke
2. Pepsi
3. RC
4. A&W
5. Sprite
6. Cactus Cooler
7. 7-Up
1. Which soda is your favorite?
type: radio
optsfrom: DRINKS
1C3. Count for RC cola
type: number
invisible: y
datatype: whole
cvalue: $_counter->get(field_id => 'Q1', option_id => 3)
In this example, the cvalue
in Q1C3 calculates the number of Completed respondents who selected 'RC' (option 3) in Q1.
Note: Get Counts should only be employed when all other possible solutions have been exhausted. Programmers might consider instead using the quotaOpen
function ("quota look ahead"), which examines how full upcoming quota buckets are, rather than the current number of Completes.
Details
- Get Counts is useful when standard
selectby
or quota methodology is not quite capable of meeting the needs of the survey designer. Use cases often involve logical statements which require counting the number of complete records fulfilling a given condition. - The parameters for
get
should be enclosed in parentheses, with each parameter being followed by a '=>' and its input — e.g.,$_counter->get(field_id => 'QX', option_id => 3, filter_condition => {QCOUNTRY => $QCOUNTRY})
. - The
field_id
parameter is required to use Get Counts so that it knows which question to reference. - If no
option_id
is specified, Get Counts returns a hash reference, allowing multiple option IDs to be used for calculations.
Parameters
Parameter | Description | Example syntax |
field_id |
Required; specifies the question or variable ID that Get Counts will examine. Surround the ID in single quotes. | field_id => 'Q1' |
option_id |
Optional; specifies the question or variable's option ID that Get Counts will examine. For non-numeric or string option IDs, include single quotes (e.g., '5A'). If not included, Get Counts will return a hash reference. |
|
filter_condition |
Optional; specifies any additional conditions to place on counted records. |
(only include records who punched '99' at Q1 in the count) |
Comments
0 comments
Please sign in to leave a comment.