Hi Yisrael,
If you still available, can you help me to put same that code in my page, below is my code, I need calculated filed “grandtotal” to show only 2 decimals , I tried but can put correctly the code you mentioned above.
Also, if possible show in my code how to mention so that filters of “staffname” and “storename” won’t repeat when new userinput added, so to show only unique feilds without repeating same .
import wixData from ‘wix-data’;
export function button1_click(event, $w) {
// no need to set the filter on the database since it’s still set
// how many items filtered in the dataset?
let count = $w(“#dataset1”).getTotalCount();
// get all of the items
$w(“#dataset1”).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.TotalScore);
});
$w(“#grandtotal”).text = “” + sumTotal / + count;
}). catch ((err) => {
console.log(err);
});
}
$w.onReady(() => {
$w(‘#dataset1’).onReady(() => {
count();
$w('#weekno , #storename , #staffname').onChange(() => {
search();
})
$w('#clear').onClick(() => {
$w('#weekno , #storename , #staffname').value = "";
$w('#dataset1').setFilter(wixData.filter())
.then(count);
});
function search() {
let filter = wixData.filter();
let weekNo = $w(“#weekno”).value;
let storeName = $w(“#storename”).value;
let staffName = $w(“#staffname”).value;
if (weekNo && weekNo !== ‘all’) {
filter = filter.eq(“weekNo”, weekNo);
}
if (storeName && storeName !== ‘all’) {
filter = filter.eq(“storeName”, storeName);
}
if (staffName && staffName !== ‘all’) {
filter = filter.eq(“staffName”, staffName);
}
$w('#dataset1').setFilter(filter)
.then(count);
}
function count() {
let total = $w(‘#dataset1’).getTotalCount();
if (total > 0) {
$w(‘#textCount’).text = ${total} result has found.
;
} else {
$w(‘#textCount’).text = “No result found!”;
}
}