There are pre-defined variable types for performing simple statistic calculations. All of them (except data series counting) operate on numeric values and use iterative expressions internally.
The pre-defined variables types are as below:
Summing a data series. The variable type is
sum.
Counting a data series. The variable type is
count or
countall.
The difference between the two
is that plain count
does not count NULL data, while
countall does.
It's equivalent to the difference between
COUNT(query1.field1) and
COUNT(*) in
SQL.
The former doesn't count NULL (empty) values,
the latter does.
Averaging in a data series.
Averaging uses two running expressions
behind the scenes. One is the
sum of
data, the other is the count
of data. The sum is divided by the count.
Here, two different calculation is possible again, depending on which counting method is used, see above. NULL data contributes 0 to the sum, but the count (the denominator in the division) may differ. The result depends on this detail.
For this reason, average and
averageall variable types exist.
Highest and lowest values of a data series.
Finding the highest and lowest values in a
data series is done by the highest
and the lowest variable types.
NULL values don't contribute to the result of either variable type, so in an all-NULL series, each variable will give a NULL result, i.e. empty when displayed.
Examples cannot be understood without the context in which they are used. Complete variable examples are in the Variable node section of the Report XML description chapter.