Hi, adding to seeramzan´s topic How to Cascade a category filter based on another filter value it would be great to have category filters that only show certain entries.
For example I want a filter for our tracking_channel, but as the question only makes sense to two of those tracking_channels I would like to preselect them.
This feature is critical for us. We have a multi-client system where each client gets filtered data (working pretty well using a hidden filter for all dashboards and views). But as the clients can see personal data from other unrelated client in the filter dropdown we have a privacy problem. This is a major problem for us as privacy is a main issue in the project.
So a possibility to further filter the dropdown values is essential (best with a extra query).
I’ve been doing something similar, but for a different reason. I’m working on cascading selections where the contents of one filter list changes the content of another list.
Solution was to embed the dashboard in an IFRAME and have drop down lists in the main page. These then pass the filter values to the IFRAME on the URL.
I have the dashboard in an iframe as well. But I don’t like the idea of having the filters outside the iframe. In this case I would have to request lists of filter values manually from the metabase db und completely duplicate functionality already present and working.
Could you use views in multiple database schema, then use the filter name to populate the schema variable in a SQL statement? Would work in MS SQL & Oracle etc. Not sure about MySQL - I think you’d need to use some sort of view name prefix.
Andrew, could you elaborate on this suggestion? Cascading is apparently on the ‘to-do’ list but until then… Working with views and SQL is my preference but your workaround with filter values to the IFRAME is also intriguing.
I’m flat out this week, but will try to publish more details next week some time. It’s not something I’ve tried, just something on my list of things to test.
Thanks Andrew, no hurry, I’d like to explore your outside the iframe solution too as I can see its value pertaining to multiple dashboards. Have found that MsSql CTEs (common-table-expressions) and TVPs (table-valued-parameters) are a no-go for populating filters based on another filter since they cannot be seen within the db schema. And dedicated tables specifically for the purpose of relating one filter to the next won’t work for more than a single user as they would be stepping over one another in the process. Quite the conundrum until the Metabase team works this into filter functionality!
Looks like my idea to select the schema based upon a parameter is no good. The parameter either isn’t being populated soon enough or it’s not a straight text substitute - shame.
@mesquest
For the filters, I just bind a series of drop downs to SQL queries in a C# project.
When a filter is changed, I change the queries slightly and refresh.
I have 3 drop downs, but only use the final one to set a parameter in the dashboard.
Another dropdown is used for the refresh options.
Yet another selects the dashboard to be displayed. I could just read the dashboard list in code, but for speed decided to just store the dashboard id and name in the web.config.
One thing to watch out for - if you remove a filter, the dashboard will need to be recreated as it’s reference is not completely removed. If it happens again, I’ll root around the database to see where I can remove the reference.