Category:
Database related
Statistical (aggregate)
Conditional
Sums values in a dataset field among records which satisfy a certain condition.
Syntax
dataset_sum_ex(
StepNo Integer,
GroupLevel Integer,
FieldName String,
Condition String
): Numeric
Parameters
StepNo specifies the step (pass) in which the function must be calculated. Possible values: 1 or 2. When it equals to 1, the corresponding function will be calculated immediately when the expression is processed. When it equals to 2, report will run in double-pass mode and the corresponding function will be calculated only in the second pass of the report processing, i.e. after the report dataset reaches the last record. Using database functions in the second pass is useful, for example, when it is needing to put the report totals in the report or group headers.
Combining different StepNo parameters in one expression (for example, database_field_val(1, 'total_sum') + database_field_val(2, 'payment_sum')) is possible, but such expression should be written so that functions with smaller StepNo will be calculated earlier.
GroupLevel specifies the aggregation group. It can have the following values:
1. Group of level 1;
2. Group of level 2;
3. Group of level 3;
0. Full report;
-1. Current page.
FieldName is the name of the field to calculate.
Condition is a boolean expression. But it must be written as a String constant (i.e. enclosed in single quotes) or a string deterministic expression.
Return value
Type: Numeric.
Examples of using
dataset_sum_ex(
1,
0,
'Salary',
'dataset_field_val(1, ''Age'') > 50'
)