Numeric data type. The values for which you want to calculate a moving sum. You can enter any valid transformation expression.
rowset
Required
Must be a positive integer literal greater than 0. Defines the rowset for which you want to calculate the moving sum. For example, if you want to calculate a moving sum for a column of data, five rows at a time, you might write an expression such as: MOVINGSUM( SALES, 5 )
filter_condition
Optional
Limits the rows in the search. The filter condition must be a numeric value or evaluate to TRUE, FALSE, or NULL. You can enter any valid transformation expression.
Return Value
Numeric value.
NULL if all values passed to the function are NULL, or if the function does not select any rows (for example, the filter condition evaluates to FALSE or NULL for all rows).
Nulls
MOVINGSUM ignores null values when calculating the moving sum. However, if all values are NULL, the function returns NULL.
Example
The following expression returns the sum of orders for a Stabilizing Vest, based on the first five rows in the SALES column, and thereafter, returns the average for the last five rows read:
MOVINGSUM( SALES, 5 )
ROW_NO
SALES
RETURN VALUE
1
600
NULL
2
504
NULL
3
36
NULL
4
100
NULL
5
550
1790
6
39
1229
7
490
1215
The function returns the sum for a set of five rows: 1790 based on rows 1 through 5, 1229 based on rows 2 through 6, and 1215 based on rows 3 through 7.