Hi
Hopefully a simple request - I want to calculate values based on inputs from two datasets.
I have two simple datasets (1) just has Name and Number of Units and (2) Unit Price. I want to create a table that calculates the Total Value of Units for each Name, i.e. for each Name in the first dataset, I want to calculate Number of Units x Unit Price (where the Unit Price is the last value added in the Unit Price dataset).
Rather than a hard coded figure (2 in the below), I want a variable based on a different dataset
export function Member_Data_afterQuery(item, context) {
//TODO: write your code here…
const Unit = item.units * 2 ;
item.UnitValue = Unit;
return item;
}
I’ve got the code to make the table work.
$w.onReady( function () {
const currentColumns = $w(“#tblMemberData”).columns;
const calculatedColumns = [{
“id”: “colUnitValue”,
“dataPath”: “UnitValue”,
“label”: “Value of units”,
“type”: “string”,
}];
$w(“#tblMemberData”).columns = currentColumns.concat(calculatedColumns);
})
Thanks in advance for any help!
Will