Sum collection and display in a table on page

Sorry that not really clear as you may have typos in that or not!.

Do you mean

|trainname| strainnamounts | sum of strainnamounts + strainncashamounts|

Update: If so then try this, if not then let me know.


Possibly simplest set up.

Add a Sum field to the CMS. You do not need to enter data.

On the Page, Connect your Table to a Dataset for the CMS .

Make sure the fields connect ok. They should all just appear in the Table.

Still with the Table selected, click the Manage Table option.
Click any fields three dots ( ) button , you do not want to display in the table and delete the field.

Add this code to the Pages Code. Make sure the IDs of the elements , table fields and dataset match yours

import wixData from 'wix-data';


$w.onReady(function () {
   //==   Wait for dataset to load
    $w("#dataset12").onReady(() => {
       //==  Get all dataset items
        $w("#dataset12").getItems(0, $w("#dataset12").getTotalCount())
            .then((result) => {
                const items = result.items;

               //==   Map dataset items to table rows
                const tableRows = items.map((item) => ({
                    trainname: item.trainname,
                   strainnamounts: item.strainnamounts,    // Match table's column ID
                   
                    sum: (item.strainnamounts +  item.strainncashamounts)         // Match table's column ID
                }));
                //==  Update table rows
                $w("#table1").rows = tableRows;
            })
            .catch((err) => {
                console.error("Error loading dataset items:", err);
            });
    });
});