I created the following custom aggregate function that help’s me get the right weighted mean.
{ text: 'MarketVal', datafield: 'MarketVal', cellsformat: 'F2',cellsalign: 'right', align: 'right', width: 200 ,aggregates: [{'<b>Weighted Mean</b>':
function (aggregatedValue, currentValue, column, record) {
// counter=counter+1;
var total = currentValue * record['Mark'];
markSum=currentValue+markSum;
var yesMarketVal=markSum;
var yesP=aggregatedValue + total;
return ((yesP)/(yesMarketVal)+aggregatedValue);
}
}] }
However, once I do grouping or carry out a filter, it changes its value but gives a wrong answer altogether.
A bizzare thing happens as well. When I change the MarketVal column width, it changes the weighted mean value by itself.
Any help to tackle this issue?