cancel
Showing results for 
Search instead for 
Did you mean: 
Community_Admin
Community Team Member
Community Team Member

Introduction

The following enables to change the value in pivot tables to specific strings, while allowing the use of conditional coloring as normal.

Step 1 - Add The Following Script To Your Pivot's Edit Script

widget.on('ready', function(){
$('td[class*=p-value] div').map(function(i, cell) { 
switch (cell.innerHTML ) {
case "10": cell.innerHTML='BAD';
break;
case "20": cell.innerHTML='OK';
break;
case "30": cell.innerHTML='MEH';
break;
default: cell.innerHTML='GOOD';
}
}) 
})

Step 2 - Modify the values in the script according to your need

You can change the 'case' values to match the original values and the "cell.innerHTML" values to the strings you wish to present.

Note: The value after default will determine what will happen with all values not matching the cases above. If you wish to leave the original values in this case simply enter "cell.innerHTML" instead of "GOOD".

Example:

After script:

Community_Admin_0-1634651775311.png

You can also achieve similar results with the following script:

fidx is the value you wish to change (starts at 1).

widget.on('ready', () => {
$('td.p-value[val="10"][fidx="1"]').text("BAD")
$('td.p-value[val="20"][fidx="1"]').text("OK")
$('td.p-value[val="30"][fidx="1"]').text("MEH")
$('td.p-value[fidx=1] div').filter(function() {return parseFloat($(this).text().replace("$","").replace(",","")) > 30;}).text("GOOD")
})
Comments
wallingfordce
9 - Travel Pro
9 - Travel Pro

Can you expand on this in the context of your example?

> fidx is the value you wish to change (starts at 1).

Does 

[fidx="1"]

Become

[Total Quantity="1"]

And what is the implication of "1" here?

Thanks in advance.

 

wallingfordce
9 - Travel Pro
9 - Travel Pro

Nevermind, sorted it. It's the "1" that changes (e.g. fidx="4") to indicate which column is impacted by the script.

Wojtek
9 - Travel Pro
9 - Travel Pro

Hi

Are those scripts still working ?

We are on L2022.4.0 . I tried both scripts and couldn't get desired result. I'm pretty sure this worked previously so I am wondering if this stopped working with last upgrade.

I would appreciate if someone could confirm, thanks.

rvickersevotix
8 - Cloud Apps
8 - Cloud Apps

Yeah would love to know if there is an update as neither of those work.

Version history
Last update:
‎10-19-2021 06:57 AM
Updated by:
Contributors
Community Toolbox

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

Product Feedback Forum:

Need additional support?:

Submit a Support Request

Sisense Privacy Policy