sumTotal of table columns

I am trying to find out if there is a way to get the sumTotal of all the items in a column on a table. My tables are already filtered with the built in filters, I didn’t code the filters. I have tried about 30 different combos and am coming up lost. The data showing up is right. Also, the tables are in repeaters so the data in the tables is being filtered based off the repeater.

Can you share the code you have and a link to the page?

The site is not published yet but here is what the page looks like.


Here is the code I have so far for the page. The repeater is connected to the stallBlocks dataset. The tables are connected to the stallSales dataset which is filter off the stallBlocks dataset. What I would like to do is some way get the sum for type 1 stalls column (since the data is already filtered perfectly) and put it in the input at under the table in the repeater.

import wixData from 'wix-data'


$w.onReady(function(){
    Sum_amounttype1();
    Sum_amounttype2();
//    totalType1();
});

//these functions are summing up total for all items in stall sales, going to need to add a filter somehow

export function Sum_amounttype1(){
  wixData.aggregate("stallSales")
  .sum("type1StallsPurchased","sumamount")
  .run()
  .then( (results) => {
      $w("#input1").value = results.items[0].sumamount;
  } );
}

export function Sum_amounttype2(){
  wixData.aggregate("stallSales")
  .sum("type2StallsPurchased","sumamount")
  .run()
  .then( (results) => {
      $w("#input2").value = results.items[0].sumamount;
  } );
}

Here is the code I am working with to make the items add up, but all I get is NaN:

import wixData from ‘wix-data’

export function button1_click(event$w) {
 //Add your code for this event here: 
 
 // 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.type1StallsPurchased);
       console.log(sumTotal);
    });
    $w("#text19").text = "" + sumTotal;
    }).catch((err) => {
       console.log(err);
    });
}