Hey all!
I am trying to calculate an average of one field of each row of my dataset. The dataset gets filtered in another functiona according to user input
My function to do the calculations looks as follows:
async function queryImpact(){
const results = await $w('#dataset2').getItems();
let len = results.totalCount;
let sumScore = 0;
for (let i=0;i<len;i++){
sumScore += results.items[i].overallScore;
}
Impact= sumScore/len;
$w('#txtTestEndNumber').text=Impact.toString();
}
I call the function after a Button Click:
export async function btnReady_click(event) {
queryImpact();
}
For some reason, in the txtTestEndNumber I get always NaN after I click the Button…
I am quite new to JS so I could use some help!