I need to calculate the growth of this year over Last Year ( (TY - LY) / LY) ... I can create a calculated field , however I'm not able to create a suitable function to calculate the total growth ...
my table
the Total Growth value should be like ( 15 - 12 ) / 12 * 100 = 25
My Code is the following
`<body>
<div id="example-table"></div>
</body>
<script>
//define data array
var tabledata = [{'LOCNAME': 'Location_A',
'SLREVENUE': 6,
'SLREVENUE_LY': 4},
{'LOCNAME': 'Location_B',
'SLREVENUE': 9,
'SLREVENUE_LY': 8}];
//initialize table
var table = new Tabulator("#example-table", {
data:tabledata, //load row data from array
layout:"fitColumns", //fit columns to width of table
columns:[ //define the table columns
{title:"Location", field:"LOCNAME"},
{title:"Revenue", field:"SLREVENUE", topCalc:"sum"},
{title:"Revenue_LY", field:"SLREVENUE_LY", topCalc:"sum"},
{title:"Growth", field:"SLGROWTH", mutator:function(value, data){return (data.SLREVENUE - data.SLREVENUE_LY) / data.SLREVENUE_LY * 100;},
}
],
});
</script>
</html>
any help please ?
I need to have a function that calculate Growth in topCalc Paramter