Adding a Calculated Column to Your CSV
Your orders.csv has unit_price and
quantity, but no total. Your products spreadsheet
has price and cost but no margin. Your HR export has first_name and last_name but no full_name.
The data you need is there. It's just not in its own column yet.
In Excel, you'd write a formula in a new column and drag it down. In SQL, you'd add an expression to your SELECT. In ExploreMyData, you pick the operation and the columns, and the computed column appears instantly.
Multiplying two columns: order totals
The most common case. You have unit_price and quantity, and you want a line_total column.
Open the toolbar and select Math from the Transform group.
Choose unit_price as the first column,
quantity as the second, and
multiply as the operation. Name the result column
line_total.
ExploreMyData generates:
unit_price * quantity AS line_total
Every row now has a computed total. The column shows up in your table just like the original columns, and you can sort, filter, or aggregate on it.
| order_id | product | unit_price | quantity | line_total |
|---|---|---|---|---|
| 1001 | Wireless Mouse | 29.99 | 3 | 89.97 |
| 1002 | USB-C Hub | 49.99 | 1 | 49.99 |
| 1003 | Laptop Stand | 34.99 | 2 | 69.98 |
| 1004 | Keyboard | 79.99 | 4 | 319.96 |
New column line_total computed as unit_price * quantity for every row.
Subtracting columns: profit margin
Your products.csv has revenue and
cost. You need profit.
Same approach. Open Math, pick revenue as the first column,
cost as the second, and subtract. Name it
profit.
The generated SQL:
revenue - cost AS profit
Want the margin as a percentage? Add another Math step: divide profit by revenue, then multiply by 100. Or use the Add Column operation for a single expression that does it all at once:
ROUND((revenue - cost) / revenue * 100, 1) AS margin_pct
Using Add Column for custom expressions
Math covers the four basic operations. But sometimes you need something more specific. That's what Add Column is for. It lets you write any DuckDB expression.
Say you need to calculate sales tax at 8.25%:
ROUND(line_total * 0.0825, 2) AS sales_tax
Or a discounted price where the discount percentage is in another column:
ROUND(unit_price * (1 - discount / 100), 2) AS discounted_price
Add Column is the escape hatch. Anything DuckDB supports as a column expression, you can use here.
| order_id | line_total | sales_tax | grand_total |
|---|---|---|---|
| 1001 | 89.97 | 7.42 | 97.39 |
| 1002 | 49.99 | 4.12 | 54.11 |
| 1003 | 69.98 | 5.77 | 75.75 |
| 1004 | 319.96 | 26.40 | 346.36 |
Expression used: ROUND(line_total * 0.0825, 2) AS sales_tax, then line_total + sales_tax AS grand_total.
Combining text columns
Not all calculated columns involve numbers. You might need to combine
first_name and
last_name into a full name.
Use Combine Columns from the Columns group. Select both columns,
set the separator to a space, and name the result
full_name.
The SQL:
COALESCE(first_name, '') || ' ' || COALESCE(last_name, '') AS full_name
The COALESCE handles NULLs. If someone only has a first name, you get "Jane " instead of NULL.
When types don't match
A common gotcha: your "price" column was imported as text because it had dollar signs or commas. Trying to multiply a VARCHAR by a number fails.
Fix this first with Convert Type. Select the column, choose DOUBLE,
and ExploreMyData will use TRY_CAST(price AS DOUBLE)
to convert it. Values that can't convert become NULL instead of crashing the whole operation.
If your price column has dollar signs, strip them first with Find & Replace (find "$", replace with ""), then convert the type. Two pipeline steps, and your column is ready for math.
Chaining calculations
Because every operation is a pipeline step, you can build on previous steps. Calculate line_total first. Then add a sales_tax column that references line_total. Then add a grand_total that sums them. Each step sees the columns created by earlier steps.
If you delete an early step, ExploreMyData shows you which downstream steps break. You can reorder and rebuild without starting over.