Changing Databases with Parameters

Is there any way to parameterize which table/database I’m targeting in a dashboard? I want to set up a sandbox environment identical to the production environment and it would make it a lot easier if I could pull the same queries but direct them at a different database.

Hey Yuri!

This is possible with some special syntax we have added to our SQL Parameters! If you add “#raw” before your SQL Parameter in your query, then you can return values from you Parameter without any of the notations involved with the parameter selection. For this instance you can use a SQL query such as the one below to switch the DB dynamically from your Parameter.

select * from {{#raw Parameter}}.table_name

It is important that you are to first make the a parameter in the worksheet with the options of your database names! You also want to make sure that the tables from the different databases that you are switching to have the same columns so that the query doesn’t fail!

1 Like