Skip to content

Calculated column: calculatedColumn

Add a column computed from an expression over existing columns.

Use cases

  • Derive total = price * quantity or margin = revenue - cost.
  • Build a ratio or percentage from two columns.

What it does

Evaluates a column-based arithmetic expression and appends the result as a new column. All original columns are preserved unchanged.

Calculated column (expression: price * quantity → total)
Before
productpricequantity
Widget9.9910
Gadget24.993
Doohickey4.9925
3 rows · 3 cols
After
productpricequantitytotalnew
Widget9.991099.9
Gadget24.99374.97
Doohickey4.9925124.75
3 rows · 4 cols

Configuration

Config keyTypeRequiredDescription
column_namestringYesNew column name
expressionstringYesArithmetic expression, e.g. price * quantity

The editor offers formula templates that fill the expression from your upstream column names.

The pandas engine evaluates the expression with DataFrame.eval; the Polars engine parses it as a SQL expression (pl.sql_expr). Column names, numbers, + - * / and parentheses behave the same on both.

Flow assistant

The flow assistant can add this node. It accepts only column references, numbers, arithmetic and a few math functions (abs, sqrt, exp, log10, log1p, sin, cos, floor, ceil), and it highlights the expression for your review before you save.

Generated Python code

These exports add total = price * quantity, preserving the input columns and row order. A missing price produces a missing total.

pandas

python
df_2 = df_1.eval('total = price * quantity')

Polars

python
df_2 = df_1.with_columns(pl.sql_expr('price * quantity').alias('total'))

Tips & common mistakes

  • Arithmetic expressions only (column names, numbers, + - * /, parentheses). For if/else logic use Conditional column; for ranks/running totals use Window function.
  • Reference columns by their exact name. Quoting for names with spaces differs between pandas eval (backticks) and Polars SQL (double quotes), so rename such columns with Rename columns first.

See also