Forum Discussion

Wojtek's avatar
Wojtek
Cloud Apps
09-09-2022

dashboard filter modified by blox looses ability to be controlled by user

I want to control dashboard filter with blox .

I create blox button with following code:

{
            "type": "Filters",
            "title": "test dashboard filters",
            "style": {
                "width": "160px",
                "background-color": "#a6a6a6"
            },
            "data": {
                "level": "months",
                "filters": [
                    {
                        "filterName": "History",
                        "filterJaql": {
                            "last": {
                                "count": 8,
                                "offset": 0
                            }
                        }
                    }
                ]
            }
        }
 
 
Once clicked it successfully updates filter on dashboard but then description changes to "filtered with custom filter" and user looses ability to change filter. when I click pen there is no options to choose from , filter box is empty:

I am looking for Last 8 month type of filter , similar to standard last 2 months available from Time frame filter group if that's any help. Anyone has any idea how to make this work ?

Thanks ,

Wojtek

5 Replies

Replies have been turned off for this discussion
  • HamzaJ's avatar
    HamzaJ
    Data Integration

    Hey Wojtek 

    You could add another filter-button that resets the datefilter. Then users can alter it again. It would be something like:

                "data": {
                    "level": "months",
                    "filters": [
                        {
                            "filterName": "History",
                            "filterJaql": {
                              "explicit": false,
                              "multiSelection": true,
                              "all": true
                            }
                        }
                    ]
                }

     

     

    • Wojtek's avatar
      Wojtek
      Cloud Apps

      That is a good suggestion HamzaJ 

      I will go with that if I wont find better solution.

      I have noticed that if parameter matches one of default filter like 'Last 2 Months' then filter remains accessible to user.

      Is there any way to add additional default filters to date filer?

      Ideally this would be dashboard not server level.

      W

      • Wojtek's avatar
        Wojtek
        Cloud Apps

        What I stated above doesn't seems to work correctly.

        {
                    "type": "Filters",
                    "title": "This Week",
                    "style": {
                        "width": "160px",
                        "background-color": "#a6a6a6"
                    },
                    "data": {
                        "level": "weeks",
                        "filters": [
                            {
                                "filterName": "Date",
                                "filterJaql": {
                                    "last": {
                                        "count": 1,
                                        "offset": 0
                                    }
                                }
                            }
                        ]
                    }
                }

        If I use correct value for count and offset then I can change filter within same level (eg. Months) which is currently selected on dashboard, as long as offset nad count will match default filter selection like "Last 2 months" But change of level doesn't seem to work. 

  • HI HamzaJ 

     I actually created custom action due to issue with level not changing , and this is working pretty good as long as no one is changing date filter type from 'Time frame' to something else like 'List'

    let itemArr = prism.activeDashboard.filters.$$items;
    let OurFilter = itemArr.find(function (x) {
        return x.jaql.title === payload.filterName
    });
    OurFilter.jaql.level = payload.level;
    OurFilter.jaql.filter.last.count = payload.count;
    OurFilter.jaql.filter.last.offset = payload.offset;
    payload.widget.dashboard.refresh();

    I was going to go ahead with your suggestion but  I am having a problem with setting up this reset button. The code you provided changes type of date filter to list so my action stops working. Do you have idea what I can change in action or reset button to make it work ? 

    • HamzaJ's avatar
      HamzaJ
      Data Integration

      Hi Wojtek 

      You could try the following code. This works for me. Do change the level to the according datelevel that you are using (and the table/column field). If you are using months and you let it set on years, it will add another date filter on year-level instead of resetting the month-filter. Just so you know.

      {
                  "type": "Filters",
                  "title": "Filter (by Dimension)",
                  "data": {
                      "filters": [
                          {
                              "filterJaql": {
                                  "explicit": false,
                                  "multiSelection": true,
                                  "all": true
                              },
                              "dim": {
                                  "title": "Year",
                                  "table": "Projects",
                                  "column": "CreatedAt",
                                  "datatype": "datetime",
                                  "level": "Years"
                              }
                          }
                      ]
                  }
              }