cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member
In cases where we want to display the difference between two columns instead of using the default Grand Totals in Pivot widgets:
Include the following widget script:
function removeCommas(num){

numClean = num.replace(/,/g,"");

return numClean;

};

widget.on("domready", function(){

/* Set text to be shown grand total row*/
var diff = "Difference";

/* set variables and clean local for reading */
var num1 = removeCommas($("#prism-mainview > div > div.errvil-warpper > div > div > div > pivot > div > div.p-fixed-cols > div > table > tbody > tr:nth-child(1) > td.p-value.p-first-data-col > div").text());
var num2 = removeCommas($("#prism-mainview > div > div.errvil-warpper > div > div > div > pivot > div > div.p-fixed-cols > div > table > tbody > tr:nth-child(2) > td.p-value.p-first-data-col > div").text());

/* Change label text*/
$("#prism-mainview > div > div.errvil-warpper > div > div > div > pivot > div > div.p-fixed-cols > div > table > tbody > tr:nth-child(3) > td.p-grand-total-row-head.p-first-data-col > div > div > span").text(diff)


/* Change difference value and add locale format*/

$("#pivot_ > tbody > tr:nth-child(3) > td.p-value.p-first-data-col.p-total-row-val > div").text((num1 - num2).toLocaleString());

});


console.log("background script run");
Result:
Disclaimer:
* Tested on version 7.0
* Only works with 2 row Pivot widgets
Version history
Last update:
‎03-02-2023 09:20 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: