cancel
Showing results for 
Search instead for 
Did you mean: 
Liliia_DevX
Sisense Team Member
Sisense Team Member

How to Show a Secondary Value in an Indicator Based on a Date Filter

This article provides an example solution on how to show a secondary value in the Indicator widget based on the date filter.

This allows you to have multiple dashboard filters but shows the secondary title and value only if the date and time filter is enabled. If it’s not and/or there are other filters enabled then the secondary title disappears.

See it in action below:

Screen_Recording_2023-08-01_at_15_55_39_AdobeExpress (1).gif


How to use it?

  1. Create an Indicator widget and add a value.
  2. Add a secondary value.
  3. Press the 3 dots menu and choose "Edit Script".

    Screenshot 2023-08-01 at 16.25.59.png
  4. Paste the following script and press "Save".

 

widget.on("processresult", function (widget, query) {
    opMap = widget.indicatorInstance._optionsMap["numericSimple"];
    const { secondaryTitle, secondary } = query.result;

    const secondaryTitleText = secondaryTitle.text;
    const secondaryValue = secondary.text;
    const dashboardFilters = prism.activeDashboard.filters.$$items;

    const dateTimeFilter = dashboardFilters.find(item => item.jaql.datatype == "datetime");
    const otherFilters = dashboardFilters.filter(item => item.jaql.datatype != "datetime");

    if (dateTimeFilter) {
        const hasEnabledOtherFilters = otherFilters.some(filter => !filter?.disabled);
        const isDateTimeFilterDisabled = dateTimeFilter?.disabled;

        if (hasEnabledOtherFilters || isDateTimeFilterDisabled) {
            secondaryTitle.text = '';
            secondary.text = '';
            opMap.borderColor = 'transparent'
        } else {
            secondaryTitle.text = secondaryTitleText;
            secondary.text = secondaryValue;
            opMap.borderColor = 'rgb(215, 215, 215)';
        }
    }
})​

 

5. Add the filters you need including any date or time filter. The script will show a secondary value only when a date filter is on. In other cases, the secondary value will be hidden. 

The example Sample Retail dashboard is attached. Please feel free to implement any additional logic and share your solutions with us!

Disclaimer: Please note that this blog post contains one possible custom workaround solution for users with similar use cases. We cannot guarantee that the custom code solution described in this post will work in every scenario or with every Sisense software version. As such, we strongly advise users to test solutions in their environment prior to deploying them to ensure that the solutions proffered function as desired in their environment. For the avoidance of doubt, the content of this blog post is provided to you “as-is” and without warranty of any kind, express, implied, or otherwise, including without limitation any warranty of security and or fitness for a particular purpose. The workaround solution described in this post incorporates custom coding, which is outside the Sisense product development environment and is, therefore, not covered by Sisense warranty and support services.

Version history
Last update:
‎01-17-2024 02:43 AM
Updated by:
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: