Query Builder > Virtual Column
Create Virtual Column from SQL Data
Virtual Columns in Draxlr let you create custom columns using formulas, text, or logic based on your existing table fields.
How to Create a Virtual Column?
-
Open the Virtual Column Modal
- In the left sidebar, click on Virtual Column.
-
Define Your Virtual Column
- Give your column a name.
- Enter your formula using the fields from your table. You can use:
- Arithmetic operations (e.g.,
price * quantity
) - String functions (e.g.,
first_name || ' ' || last_name
) - Conditional logic (e.g.,
CASE WHEN amount > 1000 THEN 'High' ELSE 'Low' END
)
- Arithmetic operations (e.g.,
- Set the data type like Text, Numeric, Boolean, Date, Date-Time.
-
Apply and Use
- Click Save or Execute to add the column to your results.
- Your new virtual column will now appear in your data table.
SQL Databases & their operations
Database Type | List of Operations / Functions |
---|---|
PostgreSQL | PostgreSQL Functions and Operators |
MySQL | MySQL Functions and Operators |
MariaDB | MariaDB Functions and Operators |
SQL Server | SQL Server Functions (Transact-SQL) |
PlanetScale | MySQL Functions and Operators (PlanetScale is MySQL compatible) |
YugabyteDB | YugabyteDB SQL Functions (YSQL/PostgreSQL) |
CockroachDB | CockroachDB Functions and Operators |
Redshift | Amazon Redshift SQL Functions |
BigQuery | BigQuery SQL Functions and Operators |
Snowflake | Snowflake SQL Functions & Operators |
ClickHouse | ClickHouse Built-in Functions |
Supabase | PostgreSQL Functions and Operators (Supabase is PostgreSQL compatible) |
What can you do with Virtual Columns?
- Filter: Apply filters using your virtual column just like any other column.
- Sort: Sort your data based on your new virtual column.
- Aggregate: Use virtual columns in aggregations (sum, average, etc.).
- Combine: Create multiple virtual columns and use them together.
Example Use Cases
- Calculations:
total_price = unit_price * quantity
- String Concatenation:
full_name = first_name || ' ' || last_name
- Category Creation:
CASE WHEN score > 80 THEN 'Pass' ELSE 'Fail' END
Tips
- Virtual columns do not modify your database; they exist only in your current query/view.
- You can edit or remove virtual columns anytime.
- Use SQL functions and expressions supported by your database.