cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
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;
  }); 
});
Version history
Last update:
‎03-02-2023 09:16 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: