Is it possible to use .sum() for dataset?

Hello, I’m using the .sum() with different filter & working fine. But I think this function only work on collection but not over dataset. Is there any way to use .sum() for dataset?

If not, then I’m displaying the repeater values from the dataset. Is there any way to find the sum of repeater values?

I didn’t add the code or screenshot as I think it’s not necessary but if someone likes to help me out with this & need both. Then please feel free to reply & I will add.

Thanks in advance!

You can do something like (let say you wish to sum up the myNumber field key values):

$w.onReady(() => {
    $w("#dataset").onReady(() => {
        $w("#dataset").getItems(0,1000)
        .then(r => {
            const items = r.items;
            const sum = items.reduce((a,c) => a + c.myNumber, 0);
        })
    })
})

Hope you’re enjoying the weekend. Thank you so much for the help. This few lines of code saves me from bulky & slow code.

Have a great day ahead!

You’re welcome.
Have a nice day to :slight_smile:

Hey, can anyone help me here

I am stuck for Summing value in repeaters.

Help me please