Get counts is a tool which allows survey programmers to look up the number of completed survey records with responses for a given question or variable options. Once this information is returned, the result can be used to drive logical conditions within the survey. This tool is useful when standard selectby or quota methodology is not quite capable of meeting the needs of the survey designer. Use cases involve logical statements which require counting the number of complete records fulfilling a given condition. For example, programming instructions might read, "For the first 100 responses, show both concepts X & Y, and rotate concepts after that." Get counts allows you to do this.
Caution! Get counts should only be employed when all other possible solutions have been exhausted. By its nature, Get Counts is not as efficient as quotas, and may cause performance issues if it is overused.
Syntax
Parameters
Parameter | Description | Syntax |
---|---|---|
field_id |
Specifies the question or variable ID that Get Counts will examine. This is required, otherwise Get Counts will not know what field to count. |
field_id=>'QX' |
option_id |
Specifies a particular option within the question at which Get Counts will be pointed. Not required, but if it is not specified Get Counts will return a hash reference. |
(for non-numeric or string option IDs, use quotes, e.g., '5A') |
filter_condition |
Specifies any additional conditions to place on counted records. In the example in the syntax column, only records with a punch of 99 at Q1 will be included in counts. |
|
Construction
This gets the counts of option 3 at QX for all completed records with the same punch at QCOUNTRY as the current survey record:
$_counter->get(field_id => 'QX', option_id => 3, filter_condition => {QCOUNTRY => $QCOUNTRY})
Here, no option_id
is specified, thus returning a hash reference so multiple option IDs can be used for calculations. The values of options 1 and 2 are summed:
my $counts = $_counter->get(field_id => 'QX'); $counts->{1} + $counts->{2}
Examples
In the following example, Get counts is used to calculate the number of completed responses with RC selected at Q3:
set list: DRINKS 1. Coke 2. Pepsi 3. RC 4. A&W 5. Sprite 6. Cactus Cooler 7. 7-Up 1. Select one drink. type: radio optsfrom: DRINKS 1C3. Count for RC cola type: text invisible: y datatype: number cvalue: $_counter->get(field_id => 'Q1', option_id => 3)
Q1C3 returns the number of completes with a punch of 3.
Suppose that a survey calls for a given brand to receive additional selection weighting, but also that this weighting ought to change after a certain number of records have been assigned that brand. In the following example, Coke receives a weight of 2 and all other brands a weight of 1 until Coke has 50 completes assigned. After the Coke bucket is filled with 50 records, the additional weighting is removed so that all brands have a weight of 1.
set list: DRINKS 1. Coke 2. Pepsi 3. RC 4. A&W 5. Sprite 6. Cactus Cooler 7. 7-Up 1. Select your favorite drinks. type: checkbox optsfrom: drinks BRANDSEL. Brand selector type: radio selectby: weight, counts optsfrom: DRINKS {if anyChecked($Q1,[id])} {weight: ( ($_counter->get(field_id => 'QBRANDSEL', option_id => 1))<50)*([id]==1) + 1} newpage Survey Continues Here
Comments
0 comments
Please sign in to leave a comment.