Forum Discussion
It is running on Linux, Sisense hosted. Also this is a table widget type object, not a pivot2 object if that helps.
Hi jfarmer , spent some time testing and I did not find a script solution that worked super well.
Some of the limitations to a script solution I found:
- Going from a numeric data type to a string data type in a table widget (value 1 to "True") did not seem to work - only worked if the data type was the same (numeric to numeric)
- The native widget event to put the logic behind ("processcell") does not fire for every page of results - just the first 10 or so pages
The script that somewhat worked (but again has the limits above, I don't recommend using it as is)
// list of column names to apply logic to
let columnTitleList = ['Column5', 'Column6']
widget.on('processcell', function(ev, widget){
//console.log(widget)
if(columnTitleList.includes(widget.item.jaql.title)){
if(widget.cell.data === 1){
widget.cell.data = 50000
//console.log(widget.cell.text)
}
else {
widget.cell.data = 60000
}
}
})
I think we can get the result you are looking for via a different method:
______________________________________________________________
If this is a regular table:
I recommend you add a custom column in the Elasticube model that contains the True or False logic and use those columns in the table widget as is -
Before model changes:
After model changes:
If this is a table with aggregation:
Unless there is a specific reason to use the table w/agg, switch the type to pivot table. Then you can use this script below (uses newer Pivot 2 API):
// List Value names
let colList = ["Value4", "Value5"]
widget.transformPivot(
{
type: ['value']
},
function (metadata, cell) {
if(colList.includes(metadata.measure.title)){
if(cell.value === "1"){
cell.content= "True"
}
else {
cell.content= "False"
}
}
}
);
Before script:
After script:
Hope that helps!