Sum Fields
Sum fields let you aggregate numeric values from arrays, producing totals that can be displayed in your document. They are commonly used for fee totals, portfolio values, and contribution summaries.
Syntax
Use the {{sum}} helper to total a numeric property across all items in an array.
Template syntax
Total portfolio value: {{sum assets "value"}}
Total annual fees: {{sum fee_schedule "annual_fee"}}Usage in tables
Sum fields are typically placed in a totals row beneath a table loop.
Table with totals
| Fund Name | Balance | Annual Fee |
|---------------|-------------|-------------|
| {{#each assets}} |
| {{name}} | {{balance}} | {{fee}} |
| {{/each}} |
| **Total** | **{{sum assets "balance"}}** | **{{sum assets "fee"}}** |Formatting
Sum fields return raw numeric values. To format as currency, wrap with a format helper:
{{formatCurrency (sum assets "balance")}}Example data
Data
{
"assets": [
{ "name": "Growth Fund", "balance": 150000, "fee": 1500 },
{ "name": "Balanced Fund", "balance": 100000, "fee": 900 },
{ "name": "Cash Fund", "balance": 50000, "fee": 250 }
]
}In this example, {{sum assets "balance"}} would output 300000 and {{sum assets "fee"}} would output 2650.