Skip to Main Content

MARKETPLACE

Switchable Dimensions

By Sisense

  • Navigation
Add-on Version 1.0.5
OS Support
Windows
Linux
Supported Sisense Versions (Linux) 7.4.3 - Latest
Last Updated January 2, 2024
Tags
HIPAA
toggle
transition

This add-on is pre-installed on Sisense in Linux environments and its version could be different. The download link is for Sisense on Windows.

The Switchable Dimensions add-on allows you to provide several views of your data.

With the Switchable Dimensions add-on, you can easily toggle between dimensions displayed in a widget.

The Switchable Dimension add-on can be set for categories, values, rows, columns or any other dimension that exists in a widget.


To install the Switchable Dimensions add-on:

  1. Download the attachment.
  2. Extract the .zip folder into the plugins folder. If the folder does not exist, create it prior to extracting the .zip file.
    For V7.1 and earlier
    : C:Program FilesSisensePrismWebplugins
    For V7.2 and later
    : C:Program FilesSisenseappplugins
  3. After those files have been unzipped there, you may also have to restart the web server.
  4. Create the widgets that will have switchable dimensions.
  5. Open the widgets script editor and paste the following code:

    prism.registerSwitchDimension({
    			widget: widget,
    			maxItemsBeforeSubMenuIsCreated: 5,  //optional                              
    			dimensions: [
    			{
    			panel: '<PANEL_NAME>', 
    			affectAllWidgets: true,  //optional (true|false)
    			dims: [
    			{
    			"index": 0,                                 
    			"dim": "[<TABLE_NAME>.<FIELD_NAME>]",                  
    			"datatype": "<DATATYPE>",                         
    			"title": "", //optional                          
    			"widgetTitleTemplate": "" //optional          
    			},
    			{
    			"index": 0,                                 
    			"dim": "[<TABLE_NAME>.<FIELD_NAME>]",                  
    			"datatype": "<DATATYPE>",                         
    			"title": "", //optional                          
    			"widgetTitleTemplate": "" //optional          
    			}
    			]
    			}
    			]
    		});
  6. In the script pasted in the previous step, replace the following placeholders with the relevant values: “maxItemsBeforeSubMenuIsCreated”: When total count of dimensions exceeds this value, the list of dimensions in the context menu will be placed under submenu. The default value is 5.
    “panel”: “<PANEL>” Define the panel name according to the switchable field’s location in the widget (the panels are located on the right side when editing a widget).
    “index”:  The field to change in the panel. “0” represents the first field, “1” represents the second field, “2” represents the third field, and so on.
    “affectAllWidgets”: Boolean value. If this value is true, switching dimension will be applied for every widget from a dashboard which has the same panel as the one from the configuration. The default value is false.
    “dim”: The dimension to be switched to. This property is case sensitive.
    “datatype”: Dimension data type. It’s important to set correct the datatype. Allowed datatypes include “datetime”, “text”, “numeric”.
    “title”:”<TITLE>” Edit the title of the field. This is displayed when right-clicking to switch dimensions.
    “widgetTitleTemplate”: A string template that enables dynamic widget titles to be displayed. When defined, a widget title will be dynamically changed according to the given template. The template must contain a {{dim}} variable that will be automatically replaced with the dimension title. The default value is the dimension title.
  7. Click Apply to save your changes and refresh the dashboard to display your switchable options.

Example 1
The widget script below allows you to switch between Country, Brand & Category, and by week for the Categories panel and Age Range, Gender for the Break-by panel. Switching between dimensions in the Break-by panel will affect all widgets from a dashboard that has the Break-by panel.

prism.registerSwitchDimension(
  {   
    widget: widget,   
    dimensions: [    
      {       
        panel: ‘categories’,
        dims: [        
          {          
            “index”:0,
            “dim”:” [country.Country]”,
            “datatype”: “text”,
            “title”:”Country”
            },        
            {          
              “index”:0,
              “dim”:”[brand.Brand]”,
              “datatype”: “text”,
              “title”:”Brand”        
            },        
            {          
              “index”:0,
              “dim”:”[category.Category]”,
              “datatype”: “text”,
              “title”:”Category”
              },  
              {
                “index”:0,
                “dim”:”[dimDate.Date]”,
                “level”: “weeks”,
                “datatype”: “datetime”,
                “title”:”Weeks” }]},
                {      
                  panel: ‘break by’,
                  affectAllWidgets: true,
                  dims: [                    
                    {         
                      “index”:0,
                      “dim”:”[Commerce.Age Range]”,
                      “datatype”: “text”,
                      “title”:”Age range”       },
                      {         
                        “index”: 0,
                        “dim”: “[Commerce.Gender]”,
                        “datatype”: “text”,
                        “title”: “Gender”       
                      }      
                      ]    
                }  
                ] 
  });

Example 2
The widget script below allows you to switch between two dimensions: Date (in weeks) <-> Strategy

Where:

  • “Date” is a date column
  • “Strategy” is a text column

There are two things you need to adjust in your Switchable Dimension code:
1. Add (Calendar) to the “dim” parameter for any date. For example:

    {
        "index":0,
        "dim":"[Commerce.Date (Calendar)]",
        "datatype": "datetime",
        "title": "Weeks"
    }

2. Add level parameter to the Date dim, which correspond to the required time granularity:

{
        "index":0,
        "dim":"[Commerce.Date (Calendar)]",
        "level": "weeks",
        "datatype": "datetime",
        "title": "Weeks"
}

As a result, your script will look like this:

prism.registerSwitchDimension({
   widget: widget,
   dimensions: [
      {
           panel: 'categories',                                    
           dims: [

              {
                 "index":0,
                 "dim":"[dimDate.Date (Calendar)]",
                 "datatype": "datetime",
                 "title":"Weeks",
                 "level": "weeks" 
              },
              {
                 "index":0,
                 "dim":"[dimStrategy.strategy]",
                 "datatype": "text",
                 "title":"strategy"
              }
            ]
        }
   ]
});

This is a free add-on. Click here to download.

18 May 2020 – Fixed bug where add-on changes dimension only for one widget on the dashboard
9 October 2019 – Added possibility to change date-time granularity

Want the latest in analytics?