Dynamic Table Total Row / Text Element

I have a database of apartment complexes. These apartments have different floor plans. Right now I have this table –


This is an example of one of the apartment complexes. I am able to find all of the floor plans associated with the complex with a query, but I would like to create a new row with some totals. Either a new row or I can place a text element that changes with each property displaying totals from the query.

For example I need the table to have something like —

I would like a total from the # of Unis column. The java script identifier for the database column is unitCount. Any ideas on how I can get a total? I am new to coding. I am guessing I can do some kind of loop to run through the rows and add up the units. Any help is very much appreciated.

Hi,

I’m assuming your table is connected to a dataset which is responsible for fetching all the items.
You can get all the items with this dataset API: wix-dataset - Velo API Reference - Wix.com

Then, like you said, you can loop over the array of items, and sum the unit count.
You can look online how to go over an array of objects in JavaScript in order to sum one of the fields.
One example: javascript - Sum values of objects in array - Stack Overflow

Good luck!

Thank you for taking the time to respond. I will look into this!