> ## Documentation Index
> Fetch the complete documentation index at: https://docs.usedatabrain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Metric Filter - Custom

> Create a Custom Dashboard/Metric Filter: Quick Instruction Manual

### Create a Metric Filter

Begin by creating a new metric filter within your dashboard.

### Write a Custom SQL Query

Create a SQL query to retrieve the data you need for dropdown options. For example:

```sql theme={"dark"}
SELECT
  "country" AS "countryname"
FROM
  "public"."table"
```

### Mention the Alias in the Option

In your filter options, refer to the alias `countryname` that you used in your SQL query.

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/MbLmlD85jcjEoVGY/images/guides/dashboard-filters.png?fit=max&auto=format&n=MbLmlD85jcjEoVGY&q=85&s=2ca30512730ece4441a24a73c1211a88" width="1538" height="1188" data-path="images/guides/dashboard-filters.png" />
</Frame>

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/oJW5seGO2mMUK4Ch/images/guides/metric-filters.png?fit=max&auto=format&n=oJW5seGO2mMUK4Ch&q=85&s=88fc9c71484cea2d159a2186ff7d6918" width="1532" height="1184" data-path="images/guides/metric-filters.png" />
</Frame>

***

### Navigate to "Apply On" Section

Go to the "Apply On" section of the dashboard filter settings.

***

### Assign Variable Name

* Assign a variable name, for example, `{{value}}`.

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

<Frame>
  <img src="https://mintcdn.com/databrainlabs-bef6850a/oJW5seGO2mMUK4Ch/images/guides/metric-filter-variable.png?fit=max&auto=format&n=oJW5seGO2mMUK4Ch&q=85&s=641fe458b9ff8385d67e5137560136ad" width="1526" height="1178" data-path="images/guides/metric-filter-variable.png" />
</Frame>

### Example Custom SQL Query with Variable Filter

1.Write Your Custom SQL:
Start by writing a basic SQL query without the filter.

```sql theme={"dark"}
SELECT
  "country" AS "country",
  "population" AS "population"
FROM
  "public"."table"
```

2.Integrate the Variable Filter:
Modify your SQL to include the variable filter.

```sql theme={"dark"}
SELECT
  "country" AS "country",
  "population" AS "population"
FROM
  "public"."table"
WHERE
  "country" = {{value}}
```

3.Resulting SQL Generated:
The resulting SQL generated by the system will incorporate your variable filter in the final output.

```sql theme={"dark"}
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"
```
