Finding the sum of a column in a table

I have a text component and need to find the sum of a column in a table. I have tried the following but no results so far. Any ideas?

{{_.sum(formatDataAsObject(tableLocations.data).deiceprice)}}
{{_.sum(tableLocations.data['deiceprice'])}}
{{ _.sumBy(tableLocations.data, 'deiceprice') }}
{{ _.sum(tableLocations.data.map(item => item.deiceprice)) }}```

You can try with something like this:

{{tableLocations.data.reduce((total, currentItem) => total + currentItem.deiceprice, 0)}}

That gave me NaN.

I figuered it out:
${{ _.sumBy(tableLocations.data, item => parseFloat(item.deicePrice)).toLocaleString('en-US', { minimumFractionDigits: 0, maximumFractionDigits: 0 }) }}

Thank you

1 Like