cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Transforming Values on Sisense - 1/0 to Yes/No

dmurphy
7 - Data Storage
7 - Data Storage

Hi, I am writing this post to enquire if it is possible to transform data on Sisense at a dashboard level.

I currently have boolean fields that display as 1 or 0 - is there any function/script that can be ran on a dashboard or widget to change these fieds to display as Yes or No?

Thanks in advance!

 

3 REPLIES 3

DRay
Community Team Member
Community Team Member

Hello @dmurphy,

I'm not fluent at Widget scripts, but something like this may work. If not please let us know and we can dig further into it. 

widget.on('render', function(widget, args){
var data = widget.queryResult.rows; // assuming your data is in rows
for (var i = 0; i < data.length; i++) {
var value = data[i].your_column_name; // replace your_column_name with the actual column name containing 1s and 0s
if (value === 1) {
data[i].your_column_name = "Yes";
} else if (value === 0) {
data[i].your_column_name = "No";
}
}
widget.queryResult.rows = data;
});

Replace `"your_column_name"` with the actual name of the column containing the 1s and 0s in your data. Make sure to configure this script in your Sisense widget script editor, and it will transform the values accordingly whenever the widget is rendered.

Thank you.

David Raynor (DRay)

dmurphy
7 - Data Storage
7 - Data Storage

Hi @DRay ,

Many thanks for your contribution. At the moment the data is remaining at 0 and 1 when running the script in the Widget Editor. Would there be any steps that must be taken after entering and saving the code to put the script into effect? I save the script and then refresh the page.

For your_column_name, does this refer to the name of the field in the Sisense cube, or what I have renamed it to on the widget? I have tried the script above for both, but unfortunately no luck!

Thanks again,

Darragh

DRay
Community Team Member
Community Team Member

Hi @dmurphy,

I'm afraid I have reached the extent of my scripting ability. ๐Ÿ˜€ I will reach out internally to see if I can find more expertise. I also encourage you to reach out to your account team. They can connect you with technical resources that are experts at things like this.

 

David Raynor (DRay)