I have a dynamic page and I would like to show sum total of a specific row on a input1 (or text box).
When i use the following code it gives me the sumtotal of the specific row but for the whole database not filtered. Your help with be greatly appreciated. Thank you.
import wixData from 'wix-data';
$w.onReady(() => {
Sum_amount();
});
export function Sum_amount(){
wixData.aggregate("INCOME-EXPENDITURE")
.sum("income","sumamount")
.run()
.then( (results) => {
$w('#input1').value = results.items[0].sumamount;
} );
}
wixData.aggregate("INCOME-EXPENDITURE")
.sum("expenditure","sumamount")
.run()
.then( (results) => {
$w('#input2').value = results.items[0].sumamount;
} );