Variable Apply On

In this page you can see the functioning of variable apply on method available in Metric/Dashboard Filters.

Using Variable Filter in Metric Filter with Custom SQL

Creating a Metric Filter with Variable Filter:

  1. Create Metric/Dashboard Filter

  2. In the “Apply On” section, choose "Variable Filter".

  3. Assign Variable Name:

    • Assign a variable name, for example, {{value}} for Metric Filter, {{global_value}} for Dashboard Filter.

    • Copy the variable {{value}} for use in your custom SQL query.

Example Custom SQL Query with Variable Filter:

  • Custom SQL you write:

    SELECT
      "country" AS "country",
      "population" AS "population"
    FROM
      "public"."table"
    
  • Custom SQL added with Variable Filter:

    SELECT
      "country" AS "country",
      "population" AS "population"
    FROM
      "public"."table"
    WHERE
      "country" = {{value}}
    

Then the Generated SQL we generate would look like this:

  • Resulting SQL:

    SELECT
      "country" AS "country",
      "population" AS "population"
    FROM
    {
      SELECT
        "country" AS "country",
        "population" AS "population"
      FROM
        "public"."table"
      WHERE
        "country" = {{value}}
    } AS "dbn_sql_table"
    

Last updated