In this article you will learn about how to perform conditional formatting in a CrossTab.
The use of cross tab or cross tabulation is to show the joint distribution of two or more variables. Similarly, you can have your customize cross tabular report based on your data. Suppose, in Helical Insight, using Adhoc a cross tabular report is generated.
Default view of Cross Tab
The above cross tab tells you about total cost involved for particular journey. As a business user, if you want to identify the cost involved for a journey is above or below budgeted cost then you can apply a conditional formatting.With the use of scripts you can generate an intended output.
Script
hi_container.set("postExecution", function(){
function checker(table){
[].forEach.call(table.rows, function(row, i){
if (i===0)
return;
[].forEach.call(row.cells, function(cell, i){
var cellData = cell.innerHTML.replace(/,/g , "");
var val = parseInt(cellData);
//Define Range based on your condition
if(val >= 50000)
cell.style.backgroundColor = 'red'; // background color is customizable
if(val >= 20000 && val<50000)
cell.style.backgroundColor = 'orange'; //background color is customizable
if(val < 20000)
cell.style.backgroundColor = 'yellow'; //background color is customizable
});
});
};
var table = document.querySelectorAll(".table");
[].forEach.call(table, checker);
});
Apply the script to generate the output
Similarly, you can apply more color customization or define the range.
For more info, reach out to us at demo@helicalinsight.com