Skip to main content
1

Access Custom SQL

On the Create Metric page, select the “Custom Query” option.
Selecting the Custom Query option from the metric creation screen
2

Query Execution

In the Query Editor, enter your custom SQL query.Use the “Format Query with AI” option to align with Databrain’s best practices.Click “Run Query” to execute.
Executing a custom SQL query in the Databrain Query Editor
3

Preview the Results

Once the query runs, review the Query Result section to view your raw SQL output in a table.You can download the results as CSV if needed.
Previewing and editing Custom SQL query results in Databrain
4

Save your Query Result

Click Use Results > to proceed. You can save it in the following ways:
1. Table ChartClick “Use as Table Chart”, configure additional settings, and save it to your dashboard.
Saving SQL query output as a table chart

2. Table Chart with Dynamic Table PropertyThis automatically adjusts to the latest structure of your SQL query result — ideal for evolving datasets using SELECT *.
3. Publish as Custom DatasetProvide a dataset name, choose a schema, and click Save.
Publishing SQL query results as a custom dataset

4. New ChartSelect your preferred chart type, configure it, and save.
Creating a new chart from SQL query results
5

Edit Custom Query

At any point, you can switch between the Chart Builder and the Query Editor.Make changes to your SQL and immediately view updated results in both areas.
Editing custom SQL query and instantly updating metric visualization
You’ve successfully created a metric using Custom SQL in Databrain!
Your query-driven metric is now active, giving you full control over data transformation, advanced logic, and custom visualizations directly from your SQL output.