Documentationbreadcrumb arrow Pluginsbreadcrumb arrow Snowflakebreadcrumb arrow Template variables
Enterprise Grafana Cloud
Last reviewed: August 18, 2026

Snowflake template variables

Use template variables to create dynamic, reusable dashboards with the Snowflake data source.

Before you begin

Supported variable types

Variable typeSupported
QueryYes
CustomYes
Data sourceYes
Ad hoc filtersNo

Ad hoc filters aren’t supported by the Snowflake data source. Grafana-native variable types that don’t depend on the data source, such as Constant, Text box, and Interval, work as usual.

Create a query variable

To add a new Snowflake query variable, refer to Add a query variable. Use your Snowflake data source as the data source for your variable query.

Any value queried from a Snowflake table can be used as a variable. Avoid selecting too many values, because doing so can cause performance issues.

Note

If the variable query returns two columns, the first column is used as the variable value and the second column is used as the display text. If the query returns a single column, that column is used as both the value and the display text.

Use variables in queries

After creating a variable, you can use it in your Snowflake queries using variable syntax.

For more information about variables, refer to Templates and variables.

You can optionally set the interpolation format. You can also configure the default interpolation format in the data source configuration.

Variable examples

The following examples show how to use variables in different scenarios.

Single-value variables

If a variable returns a single value, use the following format.

The example below assumes you have set sqlstring as default interpolation and you have two variables:

  • queryTypeSingle with value SELECT
  • limit with value 2

Query with variables:

SQL
SELECT query_type FROM snowflake.account_usage.query_history WHERE query_type = ${queryTypeSingle} LIMIT ${limit:raw}

Interpolated query:

SQL
SELECT query_type FROM snowflake.account_usage.query_history WHERE query_type = 'SELECT' LIMIT 2

Note

The default variable interpolation type sqlstring was introduced in version 1.2. From this version, you can set the default interpolation type to sqlstring.

Prior to version 1.2 of the plugin, or if you use none as the default interpolation type, write the same query as follows:

SQL
SELECT query_type FROM snowflake.account_usage.query_history WHERE query_type = '${queryTypeSingle}' LIMIT ${limit:raw}

Multi-value variables with sqlstring interpolation

When consuming a variable that returns multiple options, use the following method.

The example below assumes you have set sqlstring as default interpolation and you have two variables:

  • queryTypeMulti with values CREATE,SELECT
  • limit with value 2

Query with variables:

SQL
SELECT query_type FROM snowflake.account_usage.query_history WHERE query_type IN (${queryTypeMulti}) LIMIT ${limit:raw}

Interpolated query:

SQL
SELECT query_type FROM snowflake.account_usage.query_history WHERE query_type IN ('CREATE','SELECT') LIMIT 2

Multi-value variables with regular expressions

To use a variable that has multiple values with pattern matching, use the regular expression format option and the regexp Snowflake function.

Use ${variable:regex} syntax:

Query with variables:

SQL
SELECT *
FROM snowflake.account_usage.query_history
WHERE query_type REGEXP '${queryType:regex}'

Interpolated query:

SQL
SELECT *
FROM snowflake.account_usage.query_history
WHERE query_type REGEXP '(DESCRIBE|CREATE_USER|DROP|TRUNCATE_TABLE|ALTER)'

Configure default interpolation

You can set a default interpolation format in the data source configuration:

  1. Navigate to Connections > Data sources.
  2. Select your Snowflake data source.
  3. In the Customization section, in the Variable Interpolation Format field, select your preferred format (for example, Sql String, which is displayed as two words in the drop-down).
  4. Click Save & test.

When set, all variables without an explicit format modifier use this default interpolation.