Table of Contents

Search

  1. Preface
  2. The Transformation Language
  3. Constants
  4. Operators
  5. Variables
  6. Dates
  7. Functions

Transformation Language Reference

Transformation Language Reference

SUM

SUM

Returns the sum of all values in the selected port. Optionally, you can apply a filter to limit the rows you read to calculate the total. You can nest only one other aggregate function within SUM, and the nested function must return a Numeric datatype.

Syntax

SUM(
numeric_value
[,
filter_condition
] )
The following table describes the arguments for this command:
Argument
Required/
Optional
Description
numeric_value
Required
Numeric datatype. Passes the values you want to add. You can enter any valid transformation expression. You can use operators to add values in different ports.
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 no rows are selected (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 38 digits.

Nulls

If a single value is NULL, SUM ignores it. However, if all values passed from the port are NULL, SUM returns NULL.

Group By

SUM groups values based on group by ports you define in the transformation, returning one result for each group.
If there is no group by port, SUM treats all rows as one group, returning one value.

Example

The following expression returns the sum of all values greater than 2000 in the Sales port:
SUM( SALES, SALES > 2000 )
SALES
2500.0
1900.0
1200.0
NULL
3458.0
4519.0
RETURN VALUE:
10477.0

Tip

You can perform arithmetic on the values passed to SUM before the function calculates the total. For example:
SUM( QTY * PRICE - DISCOUNT )

0 COMMENTS

We’d like to hear from you!