Metric Filter - Variable
Variable Filter in Metric Filter: Quick Instruction Manual
Last updated
Variable Filter in Metric Filter: Quick Instruction Manual
Last updated
Master dynamic filtering in DataBrain with Variable Filters—your key to building flexible, interactive metrics. This guide demonstrates how to transform static SQL queries into dynamic data explorations, empowering users to filter complex datasets effortlessly.
Creating a Metric Filter with Variable Filter:
Create Metric Filter
In the “Apply On” section, choose "Variable Filter".
Assign Variable Name:
Assign a variable name, for example, {{value}}
.
Copy the variable {{value}}
for use in your custom SQL query.
Scenario:
Imagine a dashboard where analysts can quickly filter population data for different countries—without needing to modify the underlying SQL query every time.
Purpose of Variable Filter:
Flexible Placement in Queries:
The Variable Filter can be used anywhere in the query (e.g., SELECT
, GROUP BY
, or nested subqueries), giving full control over data analysis.
Example Custom SQL Query with Variable Filter:
Custom SQL you write:
Custom SQL added with Variable Filter:
Then the Generated SQL we generate would look like this:
Resulting SQL:
Working:
The initial SQL query retrieves all country population data.
The Variable Filter dynamically adds a condition using {{value}}
.
When a user selects a country from the dashboard, the filter updates the query.
The results are filtered instantly based on the selected country.