Shape · Columns

Add Column

Adds a column worked out by a formula, a fixed value, today's date or the current time, or a parameter. For example, margin = Price − Cost. Excel's finance functions such as PMT work here by name; see Formulas and finance functions.

Also known as: Formula, calculated field

How it works

Click Add column, give the column a name and choose what fills it. Formula is a DuckDB SQL expression over the input's columns; double-quote a name with spaces, and write conditions as IF qty > 10 THEN 'bulk' ELSE 'single' or a CASE whose END you may leave out. Value writes one fixed value cast to Text, Integer, Double, Boolean or Date. Today and Now write the current date and timestamp. Param reads the first row of the chosen column of a table wired into the params port, so one small table can drive several nodes. Excel's finance functions such as PMT are available by name in a formula; the presets in the add-node menu fill one in for you.

Inputs and outputs

Inputs

  • data — Table

Outputs

  • data — Table

Settings

The Attributes panel of Add Column, as in the app: the controls work, but nothing runs — there is no data behind it.

The same settings, as the Assistant writes them
{
  columns: [{ name: string, kind: 'expression' | 'constant' | 'today' | 'now' | 'param', expression?: string, value?: string, valueType?: 'string' | 'integer' | 'double' | 'boolean' | 'date', paramColumn?: string }]
}

kind 'expression' = raw DuckDB SQL over the input's columns, double-quoting a name with spaces (e.g. "Price - Target", or "CASE WHEN qty > 10 THEN 'bulk' ELSE 'single' END" — a CASE may omit its END); 'constant' = a fixed value cast to valueType; 'today'/'now' = current_date/current_timestamp; 'param' = row-0 value of paramColumn from the table wired into the params port, cast to valueType (#631)

Ready-made variants

The add-node search also lists these, each adding a Add Column already set up:

Example

You want a margin and a size label on every order line. Add margin as a Formula "Unit Price" - Cost, and size as a Formula IF qty > 10 THEN 'bulk' ELSE 'single'.

Unit PriceCostqtymarginsize
12.508.0034.50single
9.007.25401.75bulk