Shape · Columns

Multi-field Formula

Applies one formula to many columns at once, such as rounding every price column. Overwrite the columns or write new ones beside them.

Also known as: Apply to many columns

How it works

Pick the Columns by hand or take every text or numeric column, then write one Formula in Add Column's dialect with [_CurrentField_] standing for the column being computed. Output is Overwrite, which replaces each column in place and keeps the column order, or New columns, which writes one new column per source right after it, named with a Prefix or Suffix you must fill in. Output type is Keep formula type by default or a cast to Text, Integer, Double, Boolean or Date. If the formula fails to bind on one column, the error names that column.

Inputs and outputs

Inputs

  • data — Table

Outputs

  • data — Table

Settings

The Attributes panel of Multi-field Formula, 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: string[]
  allTextColumns?: boolean
  allNumericColumns?: boolean
  expression: string
  mode?: "overwrite"|"new"
  affixPosition?: "prefix"|"suffix"
  affix?: string
  outputType?: ""|"string"|"integer"|"double"|"boolean"|"date"
}

expression = raw DuckDB SQL (Add Column's formula dialect) with [_CurrentField_] for the column being computed, e.g. "ROUND([_CurrentField_] * 1.23, 2)"; mode "new" writes <affix>+name (prefix) or name+<affix> (suffix) right after each source column; omit affix for the suggested _new suffix (new_ prefix), which takes _2, _3… on a name already in use; outputType "" keeps the formula's own type

Example

Six net price columns need a gross version. Pick the six columns, enter ROUND([_CurrentField_] * 1.23, 2), set Output to New columns with a Suffix of _gross, and each price_x gets a price_x_gross beside it.