Field Filters are incompatible with aliasing - then how can I?


This is in reference to: Field Filters are incompatible with aliasing

I'm bumping into this constraint over and over, and it's getting irritating.
My use case is that I have 2 tables A and B, they both have a column called "xyz", plus their own other columns. Table A contains business data. Table B is a dictionary.

I want to
select * from A a inner join B b on = b.cde where {{xyz}}

where xyz is a B: xyz field filter.
Unfortunately it does not work since I would need to write {{}}, but "Field Filters are incompatible with aliasing".

Okay, if so then how can I use my dictionary table's values in a drop-down query filter in cases when my dictionary needs to be aliased to be used in a query?

Also what I am missing is the ability to add my own category-type filter defined in Metabase, not based on values taken from a table, for example a dropdown with option 1, value "ABC", option 2, value "CDE", etc. Is this possible?

Radek Cichocki

Hi @rcichocki
Why can't you just not use aliases and just use the real table reference instead? Your example:
select * from A inner join B on = B.cde where {{xyz}}
Metabase will automatically include the full reference, since you have selected that in the sidebar.

Hi @flamber,

Because I often need to use correlated sub-queries and I'd like to use Metabase's filters in those sub-queries. I often need to use the same table's name in a few contexts in one SQL query due to sub-queries. I need aliases, otherwise the SQL query won't run due to ambuguity of column names.

Without aliases, my queries aren't doable.
With aliases, my queries aren't filtrable in Metabase due to the lack of support for aliases in filters.
This constraint is incomprehensible to me, I think it's technically doable to implement filters in Metabase so they know which table they should look at, but based on its alias from the query.

Anyway, this is not supported and I don't know if it ever will be supported.

Is there any way I can work around this?

@rcichocki Have a look in the issue comments for various workarounds: - upvote by clicking :+1: on the first post

@flamber Thank you, done.