The sum helper adds all numeric elements of an array field in integrator.io. Pass a single array field; sum flattens nested arrays and skips non-numeric elements. The helper accepts integers, floats, and numeric strings. To add several separate values or fields, use the add helper instead.
Syntax
{{sum arrayField}}
arrayField -- A field that contains an array of numbers. sum evaluates only its first argument. If you pass several separate values, the extra arguments are ignored: {{sum 5 10 20}} renders 5, not 35.
Examples
Sum an array of numbers
{{sum record.items}}
Input: record.items is [2, 5, 7, 8, 9]
Output: 31
Sum a larger array
{{sum record.items}}
Input: record.items is [50, 10, 10, 10, 5, 5, 60, 10, 10, 10, 5, 5, 50, 10, 10, 10, 10]
Output: 280
Sum the result of an expression
{{sum (multiply 2 55)}}
Evaluates (multiply 2 55) first, then returns 110. A single numeric argument is returned as is.
Add separate fields with add
{{add record.tax record.shipping record.discount}}
Use add, not sum, when the values are separate fields or literals rather than elements of one array.
Usage notes
-
sumtakes one array argument. To add separate values (for example,{{add 5 10 20}}), use theaddhelper. - Non-numeric elements in the array are skipped. Only integers, floats, and numeric strings are included in the total.
- You can nest another helper as the argument --
sumevaluates the expression first, then adds the result. - Use triple braces (
{{{ }}}) if you need the exact raw numeric output without automatic formatting.