How to filter an array and sum the total
i have a JSON data as follows:
{
"transactions": [
{"city":"toronto", "sales":1234.42, "account":"john"},
{"city":"toronto","sales":4502.54, "account":"mary"},
{"city":"montreal","sales":520.04, "account":"tony"}
]
}
In Word, i create a table to show sales, filtered for "toronto" using the "discard-if" expression.
I've added a table footer that i want to perform a "sum" on "sales" using JSONata's $sum function: Numeric aggregation functions · JSONata
The sum fuction operates on all elements of the array instead of the filtered array. Is there a way to dynamically sum on the filtered array? Is this supported?
Thanks for any guidance.
