How to Sum full Row Of a Specific Column ?

Hi I Wanted To add up all elements in a specific columns in a DATABASE after filtering them with months and years and .
Here is my code for the total column sum which is not working :

export function button6_click(event) {
$w(‘#button7’).show();
//Add your code for this event here:
}
export function button8_click(event, $w) {

// no need to set the filter on the database since it’s still set

// how many items filtered in the dataset?
let count = $w(“#dataset2”).getTotalCount();

// get all of the items
$w(“#dataset2”).getItems(0, count)
.then((results) => {
let sumTotal = 0; // declare sum
let items = results.items;
items.forEach(item => {
// the amount is a string so convert
sumTotal = sumTotal + Number(item.amount);
});
$w(“#text15”).text = “” + sumTotal;
}). catch ((err) => {
console.log(err);
});
}

I Want to seperately add all the GSTprice and Total cost with filter and without filter(For Total accounting Details.
So How Can I Achieve that ?

Thanks In Advance

Hi!

Check out these forum posts that are implementing similar functionality that you are trying to achieve:

https://www.wix.com/corvid/forum/community-discussion/sum-function-calculating-a-column
https://www.wix.com/code/home/forum/community-discussion/trying-to-sum-db-values-with-a-loop
https://www.wix.com/corvid/forum/community-discussion/sum-up-a-column-in-a-dataset