Returns the sum of all values in the selected field. 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 data type. You cannot nest aggregate functions in an elastic mapping.

Use only in mapping tasks.

SUM( numeric_value [, filter_condition ] )

Argument | Required/ Optional | Description |
---|---|---|

numeric_value | Required | Numeric data type. Passes the values you want to add. You can enter any valid transformation expression. You can use operators to add values in different fields. |

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. |

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 a single value is NULL, SUM ignores it. However, if all values passed from the field are NULL, SUM returns NULL.

SUM groups values based on group by fields you define in the transformation, returning one result for each group.

If there is no group by field, SUM treats all rows as one group, returning one value.

The following expression returns the sum of all values greater than 2000 in the Sales field:

SUM( SALES, SALES > 2000 )

SALES |
---|

2500.0 |

1900.0 |

1200.0 |

NULL |

3458.0 |

4519.0 |

RETURN VALUE: 10477.0 |

You can perform arithmetic on the values passed to SUM before the function calculates the total. For example:

SUM( QTY * PRICE - DISCOUNT )

© Copyright Informatica LLC 2007, 2021