cancel
Showing results for 
Search instead for 
Did you mean: 

How to Have Break By Switchable Dimensions Update Title

Astroraf
11 - Data Pipeline
11 - Data Pipeline

I am trying to have the Break By Update the title of the Switchable Dimension rather than dimension.

My script goes as follows. 

 

prism.registerSwitchDimension({
    widget: widget,
    widgetTitleTemplate: "{{val}} By {{dim}}", // Dynamically updates title with value and dimension
    maxItemsBeforeSubMenuIsCreated: 5, // Keeps the menu clean if more dimensions are added
    dimensions: [
        {
            panel: 'break by', // Ensure this matches the panel name in your widget
            dims: [
                {
                    "index": 0,
                    "dim": "[GMV_ORDERS_DASH_UNION.SUPPLIER]",
                    "datatype": "text",
                    "title": "Supplier",
                    "widgetTitleTemplate": "{{val}} By Supplier"
                },
                {
                    "index": 0,
                    "dim": "[GMV_ORDERS_DASH_UNION.MANUFACTURER]",
                    "datatype": "text",
                    "title": "Manufacturer",
                    "widgetTitleTemplate": "{{val}} By Manufacturer"
                },
                {
                    "index": 0,
                    "dim": "[GMV_ORDERS_DASH_UNION.CUSTOMER]",
                    "datatype": "text",
                    "title": "Customer",
                    "widgetTitleTemplate": "{{val}} By Customer"
                }
            ]
        }
    ]
});

@DRay @Liliia_DevX 

6 REPLIES 6

JeremyFriedel
Sisense Team Member
Sisense Team Member

Hi Astroraf,

If the only change needed is the title, and not the `dim` parameter, then the config can be setup very similar to the example shared, except the `dim` would be set the same for all options (and all other parameters) but the title would differ for the options, this would modify the title.

 

DRay
Community Team Leader
Community Team Leader

Hello @Astroraf,

I’m following up to see if the solution offered by @JeremyFriedel worked for you.

If so, please click the 'Accept as Solution' button on their post. That way other users with the same questions can find the answer. If not, please let us know so that we can continue to help.

Thank you.

David Raynor (DRay)

Astroraf
11 - Data Pipeline
11 - Data Pipeline

Hi @JeremyFriedel,

I am a bit confused about what needs to change in my code. Is it the widget title template that needs to change in each of the dims: []?

JeremyFriedel
Sisense Team Member
Sisense Team Member

Hi Astroraf,

Both the title and widgetTitleTemplate  can differ in each of the Dim's if needed. widgetTitleTemplate is an optional parameter, but can be included in each dim if needed.

Astroraf
11 - Data Pipeline
11 - Data Pipeline

Hi @JeremyFriedel I am still unsure what you mean by this.

For me to have the dimension update the title of the widget does my formatting have to be:

widgetTitleTemplate: "{{val}} By {{dim}}",

Where each individual dimension that is changing also needs the WidgetTitleTemplate to have this coded as such:

"widgetTitleTemplate": "{{val}} By {{dim}}"
or
"widgetTitleTemplate": "{{val}} By Supplier"
or 
"widgetTitleTemplate": "Revenue By {{dim}}"

I am just trying to understand the syntax of this solution. 

JeremyFriedel
Sisense Team Member
Sisense Team Member

Hi Astroraf,

 

To clarify the template variables shared in the examples to show how those option will differ:

 

The {{val}} template will return all the values separated by "And". 

The {{dim}} parameter differs based on whether it is placed in the global widgetTitleTemplate, or in the dim array.

This differences is:

For the global widgetTitleTemplate:

{{dim}} is replaced with all dimensions separated by "And"
 
For the dim array:
 
{{dim}} variable which returns the dimension's title
 
The complete example from this plugin's Readme file using widgetTemplateTitle may be helpful:

prism.registerSwitchDimension({
    widget: widget,
    widgetTitleTemplate: "{{val}} By {{dim}}", // When global widget title template is defined, the widget title will be dynamically calculated on widget load. {{dim}} is replaced with all dimensions separated by "And" and  {{val}} is replaced with all the values separated by "And".
    maxItemsBeforeSubMenuIsCreated: 5, // Optional property that defines the max number of dimensions in context menu (default value is 5). When the limit is exceeded, all dimensions will be placed within a sub menu.
    dimensions: [
        {
            panel: 'categories', // Panel name for dimensions
            dims: [
                {
                    "index": 0, // Dimension index, make sure that in your panel you have a dimension with the same index.
                    "dim": "[country.Country]", // Dimension string (case sensitive)
                    "datatype": "text", // Datatype
                    "title": "country", // Caption for menu item
                    "widgetTitleTemplate": "Revenue By {{dim}}" // Optional property that specifies widget title according to changes. Template must contain {{dim}} variable which specifies the dimension's title (default value is title of dimension).
                },
                {
                    "index":0,
                    "dim":"[brand.Brand]",
                    "datatype": "text",
                    "title":"brand",
                    "widgetTitleTemplate": "Revenue By {{dim}}"
                },
                {
                    "index":0,
                    "dim":"[category.Category]",
                    "datatype": "text",
                    "title":"category",
                    "widgetTitleTemplate": "Revenue By {{dim}}"
                }
            ]
        }
    ]
});
 
Both the global and dim array widgetTitleTemplate are optional, and do not have to be included if not needed.