Forum Discussion

janaya71's avatar
janaya71
Cloud Apps
02-13-2025
Solved

Blox Search Field usage for multiple columns

Hi, I'm creating a dashboard with a table with multiple columns containing text.  I've created individual filters for the columns.  I tried adding the Blox Search Field widget but it is only allowing me to search one column.  I created multiple buttons to search and clear each column.  Is it possible to create one button that searches all buttons?  Here is an image of the Search Field widget with my current implementation:

 

  • janaya71 is the below script the same script you're currently using for the BloX custom action? If so, all you need to do is add the three fields into the BloX widget, because the script is already set to loop through all slicer fields (those under "Items" on the left panel).

    By default all filters are combined with an AND logic, but this can be changed using Filter Relationship. If this feature is not already turned on, you can enable it in the Admin page (App Configuration -> Feature Management -> Filters -> Filter Relationship). This is an example of a customized filter relationship where three filters (Brand, Category, and Country) are combined using OR, and then the result of it is combined using AND with all other filters:

    I also attached a dashboard file that demonstrates this example using the Sample ECommerce cube. Note that you need to change the file extension from .txt to .dash before importing it into your environment, and the Filter Relationship feature needs to be enabled.

    SearchBar BloX custom action:

     

    //Variable that stores the Data Source
    var dataSource = payload.widget.datasource
    //Variable that stores the user input
    var userInput = payload.data.userInput;
    
    payload.widget.metadata.panels[0].items.forEach(function(item){
        var column = item.jaql.column
        var dimension = item.jaql.dim
        var table = item.jaql.table
        var title = item.jaql.title
    
        //Variable that stores the JAQL to add
        var topJAQL = {
            jaql:{
                        datasource: dataSource,
                        table: table,
                        column: column,
                        dim: dimension,
                        datatype: "text",
                        merged: true,
                        title: title,
                        filter: {
                            "contains": userInput
                        }				
                }
            }
    
        payload.widget.dashboard.filters.update(topJAQL)
    })
    
    payload.widget.dashboard.refresh()
    

     

  • janaya71 Did you add the three filter fields to the BloX widget? They need to be added into the Items section on the left panel. If they are already added and the button is still not working, could you check the browser console, and see if there is any error message when you click the button?

    To do this:

    1. Click the three-dot menu button of the browser (Chrome) in the top right corner
    2. Select More Tools
    3. Select Developer Tools
    4. Click the Console tab
    5. Click the BloX button and check if there is any message on the Console window

8 Replies

  • Hi janaya71, could you clarify how you'd like the search to work? Are you expecting a single search button to apply the same input across the three filters (Request ID, Request Name, and Request Text)? If so, these columns have different values (and possibly different data types), so applying the same text values to all three filters will likely lead to no results. Or do you want an OR-based search across these columns to return any matching rows, regardless of which column contains the input?

    If the goal is to search one column at a time, how would the button differentiate the user input and determine whether to search it in the Request ID, Request Name, or Request Text filters? Let me know what you're aiming for, and we can explore possible solutions.

  • Thanks for the follow up.  So I have a table with multiple columns.  3 of those columns are Reqt ID, Name, and text.  They all contain string data.  Using the Search field, a text string is entered. Depending on the button selected, a column is searched.  I would like it so that one button would search all 3 columns, so that it would show all results found in the table.  I believe an OR-based search is what I'm looking for.

    • TriAnthony's avatar
      TriAnthony
      Admin

      janaya71 is the below script the same script you're currently using for the BloX custom action? If so, all you need to do is add the three fields into the BloX widget, because the script is already set to loop through all slicer fields (those under "Items" on the left panel).

      By default all filters are combined with an AND logic, but this can be changed using Filter Relationship. If this feature is not already turned on, you can enable it in the Admin page (App Configuration -> Feature Management -> Filters -> Filter Relationship). This is an example of a customized filter relationship where three filters (Brand, Category, and Country) are combined using OR, and then the result of it is combined using AND with all other filters:

      I also attached a dashboard file that demonstrates this example using the Sample ECommerce cube. Note that you need to change the file extension from .txt to .dash before importing it into your environment, and the Filter Relationship feature needs to be enabled.

      SearchBar BloX custom action:

       

      //Variable that stores the Data Source
      var dataSource = payload.widget.datasource
      //Variable that stores the user input
      var userInput = payload.data.userInput;
      
      payload.widget.metadata.panels[0].items.forEach(function(item){
          var column = item.jaql.column
          var dimension = item.jaql.dim
          var table = item.jaql.table
          var title = item.jaql.title
      
          //Variable that stores the JAQL to add
          var topJAQL = {
              jaql:{
                          datasource: dataSource,
                          table: table,
                          column: column,
                          dim: dimension,
                          datatype: "text",
                          merged: true,
                          title: title,
                          filter: {
                              "contains": userInput
                          }				
                  }
              }
      
          payload.widget.dashboard.filters.update(topJAQL)
      })
      
      payload.widget.dashboard.refresh()
      

       

      • janaya71's avatar
        janaya71
        Cloud Apps

        Thank you for this.  I was able to get this working with the Sample Ecommerce Elasticube.  But when I try to implement this on my Elasticube, the buttons don't do anything.  From my Elasticube, I create a dashboard selecting a few data sets to display.  I've created the filters and set the filter relationships.  For the buttons I use the same actions as in the Sample Ecommerce.  Do I need to create new actions for this dashboard specifically? Am I needing to declare the filters to use somewhere?