GROUPBY macro
The GROUPBY macro is available only in IBM® Campaign.
Syntax
GROUPBY(group_field, keyword, rolled_field [,output_field])
Parameters
*
Specifies the variable over which records are grouped (that is, all the same values of the specified variable are grouped together).
*
Specifies the summary roll-up function to perform on the rolled-field.
*
Specifies the variable to be summarized or rolled up.
*
Identifies an alternate variable to be returned for a single row of a group and can be used only with the keywords MinOf, MaxOf, and MedianOf.
Description
GROUPBY summarizes across multiple rows of data within a group. The output of this function is a single column. The output is the result of the operation specified by keyword on the rolled_field over the homogeneous group specified by the group_field. If there is more than one answer satisfying a specified condition, the first one encountered is returned.
If the optional output_field is not supplied, then the output is the result of the operation on rolled_field. If output_field is supplied, then the result is the output_field of the row within the group.
If there are multiple rows within a group that satisfy the specified condition (for example, there are ties for the max value), the output-field associated with the first row satisfying the condition is returned.
*
Supported keywords are as follows (case insensitive):
Returns the number of records in each group (rolled_field can be numeric or string; the returned value is the same regardless of the value of rolled_field).
Returns the minimum value of rolled_field in each group (rolled_field can be numeric or string; if rolled_field is a string, the value closest to the beginning of the alphabet where alphabetically sorted is returned).
Returns the maximum value of rolled_field in each group (rolled_field can be numeric or string; if rolled_field is a string, the value closest to the end of the alphabet when alphabetically sorted is returned).
Returns the number of distinct values of rolled_field in each group (rolled_field can be numeric or string).
Returns the average value of rolled_field in each group (rolled_field must be numeric).
Returns the modal value (that is, the most commonly occurring value) of rolled_field in each group (rolled_field can be numeric or string).
Returns the median value (that is, the middle value when sorted by rolled_field) of rolled_field in each group (rolled_field can be numeric or string; if rolled_field is a string, the values are sorted alphabetically).
Returns the order of rolled_field in each group (rolled_field must be numeric). If multiple records have the same value, they all receive the same value.
Returns the sum of rolled_field in each group (rolled_field must be numeric).
Returns the standard deviation of rolled_field in each group (rolled_field must be numeric).
Examples