Use the sum helper to add multiple numeric values or all elements of an array. It accepts either an array from a field (e.g., record.items) or one or more individual numeric fields/values. This can handle integers, floats, and numeric strings.
{{sum field1 field2 field3}}
-
fieldX: One or more fields or variables containing numeric data. If a single argument is an array,
sumprocesses each element. If multiple arguments are passed,sumadds them all together.
-
Summing an array of numbers
If
record.itemsis[2, 5, 7, 8, 9]:{{sum record.items}}produces
31. -
Summing a larger set of array elements
If
record.itemsis:[ 50, 10, 10, 10, 5, 5, 60, 10, 10, 10, 5, 5, 50, 10, 10, 10, 10 ]
then
{{sum record.items}}returns290. -
Adding numeric fields together
{{sum record.tax record.shipping record.discount}}This calculates the sum of three numeric fields within
record. -
Using expressions for intermediate calculations
{{sum (multiply 2 55)}}Here, the helper sums the result of
(multiply 2 55), which is110.
Tip
-
If you pass multiple arguments (e.g.,
{{sum 5 10 20}}),sumadds all of them and returns the total. -
When passing a single array, ensure all elements are valid numbers; otherwise, the helper might skip or misinterpret them.
-
Triple braces (
{{{ }}}) generally aren’t necessary unless you require the exact numeric output without any automatic formatting.