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

Summary

This article provides guidance on how to change time periods on the dashboard using Blox in Sisense. The filter example is displayed on the screenshot below.

Liliia_DevX_0-1726494569329.png


Step-by-Step Instructions

  1. Understanding the Use-Case:

    • Users often create date range buttons linked to dashboard filters for periods like “Last 90 Days,” “Last 30 Days,” etc.
    • The issue arises when there is a requirement to change the time period from "Last One Day" to "Last 1 Month" (different date granularity).
  2. Solution Overview:

    • Implement a custom action in the Blox editor to apply levels to the filters, ensuring the correct time period is selected.
  3. Implementing the Custom Action:

    • Create a Blox widget with the dates buttons. The example template is attached.
    • Create a custom action to allow you to pass the level into the filter without needing additional scripts. To do so, click "Create Action" -> add "setFilterWithLevel" as an Action Name.
    • Then add the following code:

 

 

let itemArr = prism.activeDashboard.filters.$$items;
let OurFilter = itemArr.find(function (x) {
    return x.jaql && x.jaql.title === payload.data.filters[0].filterName
});
OurFilter.jaql.level = payload.data.level;
OurFilter.jaql.filter = payload.data.filters[0].filterJaql;
payload.widget.dashboard.filters.update(OurFilter, { save: true, refresh: true });

 

 

Liliia_DevX_0-1726495183434.png

  • And press "Create":

Liliia_DevX_1-1726495249699.png

  • Ensure the custom action correctly maps each button to its respective time period level (e.g., days, months, quarters, years).

    4. Testing the Solution:

    • Test the buttons to ensure they change the time period as expected.
    • Verify that the custom action works without requiring multiple clicks.

Troubleshooting Tips

  • If the buttons still do not work as expected, double-check the custom action settings in the Blox editor.
  • Ensure that the dashboard filters are correctly linked to the custom actions.

Supplementary Information

  • For further assistance, contact Sisense support or refer to the Sisense community forums for additional insights and shared solutions.

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.

Rate this article:
Comments
DRay
Community Team Leader
Community Team Leader

Want to learn more about how to use Blox? You're in luck! We have Blox tutorials here, https://docs.sisense.com/main/SisenseLinux/sisense-blox-tutorials.htm, and here, https://academy.sisense.com/blox-lite-version

Version history
Last update:
‎09-17-2024 11:39 AM
Updated by: