[SOLVED] SUM_BY_KEY Function questions

Hello Everyone! Can you help me with the SUM_BY_KEY function?

I’m using a local storage and it is called “Local_Full”

I have a field called “Amount” and it is number field.

Let’s say I have four rows of record with 50, 100, 50, 30 in “Amount” field.

I would like to get the sum of all these numbers.

I tried SUM_BY_KEY(data.Local_Full, "Amount) and I’m not getting any return.

Any suggestions?

Tried SUM(Amount)?
I’m not understanding well the exact context / data structure so that’s my suggestion so far.

:frowning: SUM didn’t work

Below is my DB structure. I have a on-device storage with only two fields ID and Amount. I would like to be able to sum all the amounts in Amount. I have added the resource as a full collection and single record on the page where I’m trying to show the sum amount.

SUM(MAP(data.Local_Full, NUMBER(item.Amount)))

This worked! Thanks @Fred_Kuzyk for telling me to use SUM

1 Like

Great, but why do you need to use the NUMBER formula, if the “amount” is already a number type?

I was curious about that, too. For some Amount values, I had decimal numbers such as 15.50 and 5.50. Is it because of the decimal numbers and I used the FORMAT_LOCALIZED_DECIMAL with 2 decimal points?

That’s still a number. Maybe that’s because of the local storage. I’m not familiar with that.