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

BloX Template - Search box to filter 2 dimensions 

This article provides a BloX template for the use case when you need a search box to be able to filter 2 dimensions at once. This solution is based on a custom action developed. See the guide for reference: Creating Custom Actions.

jcordell_0-1695933061649.png

 

1. Import a Blox template attached. 

2. Create a new custom action called "filterByDimensions" with the code below: 

 

const searchInput = document.getElementById('bloxFiltersInput').getAttribute('value')
if (searchInput) {

    payload.data.filters.forEach(filterName => {
        payload.widget.dashboard.filters.$$items.find(f => f.jaql.title === filterName).jaql.filter = {}
        payload.widget.dashboard.filters.$$items.find(f => f.jaql.title === filterName).jaql.filter.contains = searchInput
    })
    payload.widget.dashboard.filters.update(payload.widget.dashboard.filters.$$items, {
        refresh: true,
        save: true
    })
}

3. Press "Next" button and paste the following code:

{
    "type": "filterByDimensions",
    "title": "title",
    "data": {
        "filters": "filters"
    }
}​

4. Click on "Create". 

5. Navigate to the "Editor" tab and update "filters" array to include your dashboard filter titles. In our case, it's "Brand" and "Category".

jcordell_1-1695933061210.png

 

Now test it out and feel free to use it as an example to develop your own solutions, and drop a comment with your experience! 😊

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
Astroraf
10 - ETL
10 - ETL

Hi @Liliia_DevX ,

 

Thanks for this great example with a 2-dimensional filter. The only issue is when you apply a term that is not related the BloX widget goes blank and you have to clear the filter from the dashboard filter on the side. I have added this reset button, but again when I search for a term that is not related the BloX filter goes blank. Is there a work around to this?

Liliia_DevX
Sisense Team Member
Sisense Team Member

@Astroraf hi! Thanks for sharing your feedback. 

Could you please check if the dashboard filters are disabled for the Blox widget? To do so, open your Blox widget in the Edit mode -> move to filters and disable the dashboard filters there: 

Liliia_DevX_0-1726642070095.png

Hope that helps! 🙂

Best Regards, Lily

Astroraf
10 - ETL
10 - ETL

Hi @Liliia_DevX 

That did the trick, thank you. 

I also wanted to make a note for anyone reading the article. Once the filter is applied you can go to the relationship editor and make this an OR statement so it searches in either column. 

Version history
Last update:
‎09-28-2023 01:33 PM
Updated by: