Incubator-superset: How to have multiple filters on dashboard affecting different charts?

Created on 9 Jan 2019  路  15Comments  路  Source: apache/incubator-superset

Make sure these boxes are checked before submitting your issue - thank you!

  • [ ] I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • [ ] I have reproduced the issue with at least the latest released version of superset.
  • [X] I have checked the issue tracker for the same issue and I haven't found one similar.

Superset version

0.27.0

Expected results

I want to compare two different time periods. So I've added two filters and two charts. Now I want that filter 1 just impacts chart 1 and filter 2 just impact chart 2.

Actual results

Filter 1 impacts both charts or just one if I fill in the JSON metadata of the dashboard the option filter_immune_slices. When I change filter 2 nothing happens or I get an "unexpected" error on filter 1 and the charts.

Steps to reproduce

Add two charts (distribution charts) showing the same data and two filter boxes (for date). Try to set different dates on the filters.

Any help would be appreciated. Maybe I'm totally wrong when trying to compare two different time scales?

answered

Most helpful comment

Oh you're right. There's currently no way to express that.

We could add a feature that would introduce new ways to express this. Something like a new dashboard metadata key that defines which chartid listen to which Filter Box (either a blacklist or whitelist approach). Though I feel like it's pushing the complexity of an area that's already overloaded...

Scoped filters is a much more elegant solution.

All 15 comments

Superset currently does not support that yet. There have been discussion about "scoped filter" in the past, which will enable you to do this but will take quite some time until we get to that point since it involves larger architectural change.

So is there any other possibility to compare the same chart but with two different periods of time? I can't imagine I am the only one who wants to use such a feature. Comparing data is essential for analysis, isn't it?

So with filter_immune_slices, filter_immune_slice_fields and timed_refresh_immune_slices, we should be able to make this work.
http://superset.apache.org/faq.html#how-to-add-dynamic-filters-to-a-dashboard

Also FYI the idea of "scoped filters" is that the filters would only apply to their context in a dashboard, so if the filter is located in the header of a tab, it applies to the tab, if it's located above the tab bar, it applies to all tabs, if it's within a section, it applies only to that section, ...

In theory you can make a dashboard behave as if it had "scoped filters" using what's documented in the FAQ entry I linked to above. It's more flexible than scoped filters (though less intuitive and much harder to setup), because you can set things up so that any filter can apply any subset of charts.

For your use case, it may be possible to do what you are trying to do using filter_immune_slice_fields with the special field __time. Your case is a bit special because you have 2 Filter Box components that emit filtering events on the same "field" (__time) and that may not be handled properly.

I have to look at the code to see whether the filter_immune_slice_fields + __time approach would work not, and if not, what it would take to make it work.

Did you try filter_immune_slice_fields using __time yet btw?

How should this help when using 2 filter boxes? Unfortunately I can't define (or I don't know how to do so to use) immune slices or fields per filter box.

Oh you're right. There's currently no way to express that.

We could add a feature that would introduce new ways to express this. Something like a new dashboard metadata key that defines which chartid listen to which Filter Box (either a blacklist or whitelist approach). Though I feel like it's pushing the complexity of an area that's already overloaded...

Scoped filters is a much more elegant solution.

You could also try to add unique identifiers in the data source(s) of the of charts which could be linked to each filter box... Pretty much in the same vein as @mistercrunch 's solution but on a smaller granularity.

@mistercrunch Hi, has there been any updates with this feature yet?

@mistercrunch Hi, any updates on the feature?

Guys any update?

Go to Edit Dashboards and choose Filters, there you will see two Tabs open one with your Filter Boxes and other with slices, Select a Filter box and you can add the slices in the filter scope from here

@Himanshu-998
I still didn't get you, here is my filter box:
image
Which option will allow me to enable slicing? I have tried checking that box but it never saves into the system. It would be really helpful if you could show an illustration.

@sedhha Yess, So now just check the Remarks checkbox and then on the right side Expand both One Dimensional and Two Dimensional, there you will be able to see all the slices you have on your dashboards/tabs check all the slices you want to add in the scope of the filter and click Save button.

I was also facing this issue that it was not saving correctly, Just try with Auto-refresh as set off once

@sedhha Yess, So now just check the Remarks checkbox and then on the right side Expand both One Dimensional and Two Dimensional, there you will be able to see all the slices you have on your dashboards/tabs check all the slices you want to add in the scope of the filter and click Save button.

I was also facing this issue that it was not saving correctly, Just try with Auto-refresh as set off once

You mean turn auto refresh off in config.py file? But then won't it affect the data fetching process?

Go to Edit Dashboards and choose Filters, there you will see two Tabs open one with your Filter Boxes and other with slices, Select a Filter box and you can add the slices in the filter scope from here

I do not see any Filters tabs. Where is it?

Go to Edit Dashboards and choose Filters, there you will see two Tabs open one with your Filter Boxes and other with slices, Select a Filter box and you can add the slices in the filter scope from here

I do not see any Filters tabs. Where is it?

Look the dashboard in edit mode, you will see it on top right.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sashank picture sashank  路  3Comments

thoralf-gutierrez picture thoralf-gutierrez  路  3Comments

XiaodiKong picture XiaodiKong  路  3Comments

vylc picture vylc  路  3Comments

lenguyenthedat picture lenguyenthedat  路  3Comments