Skip to content

Sum

aggregating category: aggregation no `||`

Returns the sum of the given parameters or the available inputs, folding ARRAY inputs element-by-element.

Without parameters, Sum adds every available input. When parameters are given, it adds only those parameters/fields. Scalars and ARRAY values mix freely in one call — an ARRAY input is folded element-by-element (the same way Min/Max fold arrays), so GetCDMTableId(@idx, :key)[] => Sum() totals all matched values.

NULL inputs and NULL/empty ARRAY elements are skipped, never poisoning the total. Output is INT when every value is an integer, otherwise FLOAT. When every input is an ARRAY the element type is unknown at parse time, so the output type defers to the destination field.

Sum accepts only numeric (INT/FLOAT) values; dates and strings are rejected at setup.

Parameters

Naddends Optional — accepts: field, FLOAT, INT

The Nth value to add. May be a field reference (scalar or ARRAY) or a static number.

Input type

  • FLOAT
  • INT
  • ARRAY

Output type

  • INT when all values are integers, otherwise FLOAT

Requires

  • All parameter and input types must be numeric (INT or FLOAT).

Examples

Sum across all inputs

Sum()

Two field references

Sum(:value1, :value2)

Total a collected ARRAY

GetCDMTableId(@line_index, :claim_id, :amount)[] => Sum()

See also

Add, Min, Max, Count