Parametrizing a complex query

As seen here I need to be able to create a variable for the database_name field. This is then setup in a dashboard which enables the viewer to see the metrics per database_name/domain.

Usually, if the WHERE statement contains only one proposition, I can delete its content, replace it with {{database_name}} and it works after setting up the variable properly.

How I can parametrize this question for the database name?

Thank you kindly,

Antoine

Hi @Antoine
Why can't you do this - perhaps I don't understand your description.

where "created_at" between '2022-01-01' and '2022-06-01'
and {{database_name}}

Bonjour Flamber :slight_smile:

I get syntax error when I write in that suggestion.

I also tried this to no avail.

I solved it by replacing the whole thing following the 'AND' in the where clause with the usual {{database_name}} Thank you! :slight_smile:

@Antoine Field Filters is without identifier, since Metabase handles that:
https://www.metabase.com/learn/sql-questions/field-filters#omit-the-direct-assignment-in-the-where-clause

1 Like

Thank you Flamber I was looking for a doc like that!