I have a collection of results that have multiple results per person and I would like the sum of all of the results per person. Can someone please assist with this? It appears that results1 shows empty. Once that is resolved, how do I make the foreach loop for each user instead of each item in the collection? Thanks in advance
This is what I have so far:
$w.onReady(function () { wixData.query("TxResults") .find() .then( (results) => { let resultCount = results.totalCount; console.log(resultCount) // get all of the items results.getItems(0, resultCount) .then((results1) => { console.log(results1) let sumTotal = 0; // declare sum let items = results1.items; items.forEach(item => { // the amount is a string so convert sumTotal = sumTotal + Number(item.totalpts); }); $w("#table1").rows = items; }).catch((err) => { console.log(err); }); } ) ; });
Hi,
Check out this article about creating a search for your site and displaying the results in a table.
Good luck :)
Or