apache / superset

Apache Superset is a Data Visualization and Data Exploration Platform
https://superset.apache.org/
Apache License 2.0
62.04k stars 13.61k forks source link

Superset Dashboard with native filter does not correctly update when opened #27787

Open pmainguet opened 6 months ago

pmainguet commented 6 months ago

Bug description

Hello Superset team

I have a dashboard with native filters on two dimensions ComId and Country that I access via the following URL:

http://xxx.com/dashboard/74/?standalone=2&native_filters=(NATIVE_FILTER-4muGsWvuM:(cache:(label:%27fr%27,validateStatus:!f,value:!(%27fr%27)),extraFormData:(filters:!((col:country,op:IN,val:!(%27fr%27)))),filterState:(label:%27fr%27,validateStatus:!f,value:!(%27fr%27)),id:NATIVE_FILTER-4muGsWvuM,ownState:()),NATIVE_FILTER-mV48ONcz5:(cache:(label:%27100565400%27,validateStatus:!f,value:!(%27100565400%27)),extraFormData:(filters:!((col:merchant_id,op:IN,val:!(%27100565400%27)))),filterState:(label:%27100565400%27,validateStatus:!f,value:!(%27100565400%27)),id:NATIVE_FILTER-mV48ONcz5,ownState:()))

The dashboard open corretly, the filters are correctly set on the left side of the screen, but the filters are not applied to the data. I need to click on "Apply Filters" to have the correct view.

Step 1 - All panels load Step 1 - all panels load

Step 2 - Unfiltered data loads Step 2 - unfiltered data loads

Step 3 - Filters load on the left side Step3 - Filters load

Step 4 - Correct view after clicking on Apply Filters Step 4 - Correct view after clicking on Apply Filters

I believe it is due to the fact the unfiltered data is first loaded and then the filters are set in the dropdown. I tried to use Jinja templating in my queries to force loading the filtered data but in that case i get an error, as the filters are not set hence my Jinja templates are empty.

Is there a way to autorefresh the dashboard after the filters are set to get the filtered view right away, or another work around ?

Tested on Superset 2 and 3

Thanks in advance

How to reproduce the bug

Open a dashboard with native filters

Screenshots/recordings

No response

Superset version

master / latest-dev

Python version

3.9

Node version

16

Browser

Chrome

Additional context

No response

Checklist

ftwegner commented 4 months ago

Here is a response from a Apache Superset PMC member:

As the GitHub issue's open status indicates, this is sadly not supported at this time. I don't think it's on anyone's near-term roadmap that I'm aware of, either. This is one of those "contributions welcome" areas if you have any engineering support in your org that might be able to contribute such a feature (e.g. an "applyFiltersInstantly=true" URL param or something along those lines.

rusackas commented 4 months ago

It may also be worth noting that when you configure dashboard filters, you can set default values, and these are automatically applied. That may or may not help, depending on your use case.

ftwegner commented 4 months ago

I got the automatic filtering solved. I found the problem. It was sitting before the keyboard. In the URL I was using the wrong value for the parameter. When applying the second "name" tag from the "targets" section as the filtering works as expected, see the screenshot below. The code from the article Apache Superset — Use URL to filter dashboards works exactly as I need it now.

native_filters=(NATIVE_FILTER-<id>:(__cache:(label:'<value>',validateStatus:!f,value:!('<value>')),extraFormData:(filters:!((col:<column>,op:IN,val:!('<value>')))),filterState:(label:'<value>',validateStatus:!f,value:!('<value>')),id:NATIVE_FILTER-<id>,ownState:()))

image

rusackas commented 4 months ago

And it applies automatically? Does that effectively close this issue?