Pivot Table Value Difference
Question: How to find value difference in Pivot table VALUE field "Total" which divides values by Month Columns.
Solution: You can solve this by the following script:
var columns = 3;
var avg = 0;
var val = '';
var temp=0;
var title = "text";
widget.on('ready', function(se, ev){
var grand_total = $("span:contains('Grand Total')");
grand_total.text(title);
$.each($("tbody tr"), function(){
var num = $("tbody tr:first").children().length - columns;
var e = element;
var w = widget;
var d = dashboard;
var cell = $(this).children().last();
for (var a = 0; a < num; a++){
cell = cell.prev();
if (avg == 0) {//debugger;
//console.log(cell.children().text());
if (cell.children().text() == " ") {//debugger;
temp = 0;
avg = 0;
}
else {
temp = parseFloat(cell.attr("val"));
avg = parseFloat(cell.attr("val"));
}
}
else {
if (cell.children().text() == " ") {
avg = 0 - temp;
}
else {
avg = parseFloat(cell.attr("val"))-temp;
}
}
}
cell = $(this).children().last();
cell.children().text(avg.toString().substring(0,8));
avg = 0;
temp = 0;
});
});
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022