Format Entire Record In Pivot Table Based On Dimension Name
Overview
In this example the script goes through the pivot line by line and when it finds "Female" it colors the entire line light pink, its associated key pair value. It does the same for the word "Male" and colors the record light blue.
Normally, you would only be able to conditionally format the value's box on the value itself, not the dimension.

Technical Overview
The colorMap object contains a key value pairing of a string and an associated color.
Set the strings you want to search for on the left as keys and the colors you want to format them as values on the right.
Make sure to keep track of your comma and quotation usage.
// edit colorMap values below
var colorMap = {
"Female" :"lightpink",
"Male" :"lightblue"
}
// don't edit below!
widget.on('ready', function (a, b){
$.each(colorMap, function(k,v){
$('#pivot_ tr:contains(' + k +')', element).css('background-color', v);
})
});
Updated 03-02-2023
intapiuser
Admin
Joined December 15, 2022