Anyway to add dynamic table name in SQL template?

Hi,

Currently I have some tables with same schema, such as, table1, table1_today, table1_sbox, table1_today_sbox

I want to build some dashboards based on these tables, all the related SQLs are the same except the table name
I don’t want to create 4 question collections, such as table1 collection, table1 sbox collection and so on which just duplicate the SQLs several times and is not good for future maintenance

I would have thought to add a SQL with text variables as following,

select count(*) from {{name}};

Unfortunately, in 0.22.2, there are quotes around the text variable, such as select count(*) from ‘table1’, this is invalid SQL statement

On the other hand, the logical changed to use the placeholder for text variables since 0.23.0, such as select count(*) from $1. The variable will NOT be bound since the SQL template is NOT a normal placeholder statement in my case

I also tried with number type, I think this is OK but I don’t want to change the table name to table_1, table_2 and so on
(select count(*) from table[[_{{name}}]] and name is number type)

Is there anyway to implement this or I just need to copy all the SQLs in dashboard for several times based on different table name?

Thanks for your great help

This is an old thread but is there any update on this? This is pretty much my use case as well.

@arpit.goyal Not until something like this gets implemented:
https://github.com/metabase/metabase/issues/4639 - upvote by clicking :+1: on the first post