Field Filter on multiple tables

Hi guys,

I’m trying to write a query that involves multiple tables but it seems like it’s not possible due to the nature of Field Filter being tied to a table’s column. Is there a way to refer to a Field Filter’s from and to directly in the query? I want to use a Field Filter so I can use the same dashboard filter as my other queries, so having two Date variables are not an option for me. That option sounds like a hack.

The query is basically:

SELECT
  (SELECT SUM(field) FROM table_a WHERE {{date}}) /
  (SELECT SUM(field) FROM table_b WHERE {{date}})

I feel like the field filter should look more like {{date:table_a.created_at}} so it can be referred to different fields in one query and generated properly. Maybe I don’t know how to use this. Please help!

3 Likes

I'm facing the exact same issue. Did you ever find a solution? Thanks!

Field Filters does not support aliasing currently:
https://github.com/metabase/metabase/issues/3324 - upvote by clicking :+1: on the first post

https://www.metabase.com/learn/sql-questions/field-filters
https://www.metabase.com/docs/latest/questions/native-editor/sql-parameters#the-field-filter-variable-type

There are a lot of upvotes on that issue sir! Do you have any idea when they plan to add alias support?

I saw your response about a lookup table in some other places. I don't have write access to the database I'm querying - can you think of any other workaround?

Thank you!

@calvin Use two Date filters instead if you don't have the option to create a lookup table. I cannot provide any timelines for any issues.