Hi there! We are using metabase for a couple of years now… but cannot find a solution for this issue:
we have MySQL tables in this format “database.name_year_month” and I want the query to use the proper table depending on the current date, i.e. on the 29th of November: “database.name_2025_11” and a week later: “database.name_2025_12”
use/set… or variables do not work.
Is there any way/workaround I can handle this in metabase? pls advice.
Metabase doesn’t support dynamic table names. There’s a lot of metadata attached to the table that Metabase has to keep track of.
MySQL 8 supports partitioned tables. Create a partitioned table and attach the month named tables as partitions. Then you can query the top level table to access the attached tables. There must be a key to identify the partition; in most cases like this you likely have a datetime column already that can serve as the key.
The partitions can be detached and dropped when no longer needed. Easy data lifecycle management.
The other way is to write a tool that uses the Metabase API to generate new questions every time a new table appears. We get lots of posts of people wanting to do this and not a lot of reports of success.