adding function before items display

i’m using wix data to create a workflow website. (1 of several projects) I am using user input data and then displaying it as an order form.
(little background) I’m in the HVAC business. We have a project that we inspect an entire apartment building then order materials, do the job, record the info from the install and finally bill the job. I’m attempting to do all of this from our new workflow website.
On the inspection all data is entered into the database for each unit. (1 building is 10 units) in the database I have 10 units with the same Building Number and same Date. I have built a dynamic collection page (not item page) that has every item that was entered into the database listed on the page. I have connected each item on the dynamic page to their respective items in the data collection.
the problem I am having is that the dynamic page is only showing 1 of the 10 units. If I change the building number it builds another dynamic page for me (that’s great, just what I expected) but I needed each page to display the totals for the building. How can I display the collective totals for these fields ?
so just to clarify… using this example, I have entered 10 separate user input forms and have 10 lines in the data collection. every entry in the data collection share 2 things, the Building Number and the Date. I have a total of 7 furnaces between the 10 lines in the data collection. I need to display them as a total not individually so it clearly shows we need 7. I have somehow got this far without having to write any code but I believe this will take added code. Is there code that I can add to the entire page that tells the page to add the items in each field title together ?

below is how the order form looks in the editor. If I goto preview mode everything that we order id displayed in the user input boxes. I entered 1 unit into the database and tested in preview mode and everything was displayed perfectly but as I added the 2nd and 3rd units into the database the data was not being added to the 1st units like I wanted. As I thought about it I never asked for the data to be displayed collectively, I guess I was expecting the computer to read my mind. I don’t know how to ask for the collection to do what I need it to do and Im about 99% sure that this is a common and simple function.
I will be VERY greatfull for some help on this one

so you want to summarize data from rows with same building id and date? if I create a function that takes building id and date and returns a virtual collection with all summed up data will that solve your issue?

Hay mike,

The way dynamic pages work, is that the fields in the URL act as a filter to the collection. If you use the house number as the field in the url, and the collection has 10 items for the same house number, you will get all 10 in the dynamic dataset of the page.

You can at this point connect the dynamic dataset to a table or gallery to show the 10 different items.

If you connect the dataset to other elements, such as inputs, texts or images, those elements only show a single element at a time - the current item of the dataset. Using the next and prev actions of the dataset you can browse the 10 elements - moving the current item between the 10 items.

If you want to summarize over those items, you can do so using code and the dataset APIs.