Search

1. Preface
2. The Transformation Language
3. Constants
4. Operators
5. Dates
6. Functions
7. Creating Custom Functions
8. Custom Function API Reference
9. POWERCENTERHELP # MOVINGSUM

Returns the sum (row-by-row) of a specified set of rows.
Optionally, you can apply a condition to filter rows before calculating the moving sum.

## Syntax

`MOVINGSUM( numeric_value, rowset [, filter_condition] )`
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
numeric_value
Required
Numeric datatype. 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).
If the return value is Decimal with precision greater than 15, you can enable high precision to ensure decimal precision up to 28 digits.

## 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 port, 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. Updated August 06, 2018

Resources