Knowledgebase: Sisense Tips
Sisense Blox - Replacing 'No Results' with custom text
Posted by Cara Smith, Last modified by James Kruss on 04 August 2021 03:04 pm

Occasionally some dashboard widgets will display placeholder text with 'No Results'.

This article will explain how to replace the 'No Results' placeholder with custom text. See image below for an example as to how a widget could look before and after the replacement. 


This does not indicate that the widget is broken, it simply indicates that the widget does not have any data or information to display based on the given query or formula set against the widget. This placeholder text may also appear if a user selects dashboard filters and again the widget has no results to display.

In order to prevent this default placeholder text from displaying we can edit how the widget will look if there are no results to show.

Step 1 - Add a new Item to the Widget

First, hit the 'Edit Widget' pencil icon on the widget to update to open the widget in a new window, then select any dimension/field to add to the widget. (The results of this field will not be read or displayed anywhere on the widget so choose anything you like.) To select the dimension/field, hit the Add '+' icon beside Items in the left hand widget panel. This will open a pop-out window where you can select your preferred field to add to the widget. (See image below. Area surrounded by green border.) Once you have selected your preferred dimension you will see it listed under Items in the left hand widget panel.

Step 2 - Add a new Value to the Widget

Next, add a new value to the widget. To do this, hit the Add '+' icon beside Values in the left hand widget panel. This will open a pop-out window where you can select the field to add to the widget. (See image below. Area surrounded by green border.) This field should be the same name of the Item selected in the previous step, the widget will automatically create this value as a count function.


Step 3 - Add HTML blank space to Widget text

Assuming the widget is already reading a value from from the data source in left hand panel prior to adding the additional value in Step 2. Simply locate the code block within the widget editor where the value is being displayed / printed onscreen, this will generally be within the text": parameter of the TextBlock element. See code snippet below and look for the line containing, "text": "{panel: **REPLACE WITH PANEL NAME** }",

{
   "type": "TextBlock",
   "class": "condition_data",
   "text": "{panel: **REPLACE WITH PANEL NAME** }",
   "horizontalAlignment": "center",
   "size": "large",
   "weight": "bold",
}


Having located the "text": parameter, add an HTML non-breaking space   to the end of the text parameter directly before the closing double quotes. It is also important to ensure there is a space before and after the   (See example below.)

{
   "type": "TextBlock",
   "class": "condition_data",
   "text": "{panel: **REPLACE WITH PANEL NAME** }   ",
   "horizontalAlignment": "center",
   "size": "large",
   "weight": "bold",
}

Step 4 - Add JavaScript to replace Non-breaking space

With your widget editor window still open, hit the 'Options' or 3 vertical dots icon found at the top of the main widget screen. This will open a dropdown with a number of options to select. (See image below) Click 'Edit Script' which will open a new window containing the widget scripts.


Within the dashboard scripts window, copy and paste the entire code block below and paste it below any existing scripts within the script editor, (if any exist), then hit Save. 

widget.on('ready', ()=> {
   $('.text-block').map(function(i, cell) { 		
       if(cell.innerHTML == "   " ) cell.innerHTML=0;
   });
})


Once saved and implemented correctly, the widget should now display a 0 in place of the default 'No Results' text.


If you have any trouble or require any further assistance, please contact Rapid Bi.

(3 vote(s))
Helpful
Not helpful

Comments (0)
Copyright © RAPID BI Pty Ltd 2020