Hello, could you create filters based on an sql query.
For example, we make a query on a table of the type:
select caption,label from table
the result will be an array where the caption value will be the value to test in the query and the label will be the displayed value in a dropdown filter.
In the query of the question we can do this
select a1,a2,a4
from table
left join table2 as t2 on t2.id = table.id
[[where t2.valuesearch = {{variable}}]]
This would solve the problem of aliases and allow to have a fully compatible filter system with complex sql queries.
For information, this is how filters are managed in Mydbr
Hi @Nounours13
Have a look here: https://www.metabase.com/learn/sql-questions/field-filters
Remove the table aliases. And Field Filter variables should not have column and operator - that is inserted automatically.
Hi flamber,
I know this solution, but sometimes, on complex queries, we need to make aliases on data joins on identical tables. And there it is impossible to make filters.
@Nounours13 Okay, the query you provided doesn't require that - see the comments of this issue:
https://github.com/metabase/metabase/issues/3324 - upvote by clicking on the first post
Your right. Create View on database and use for join.
It's the solution to use Metabase filters on complex query