Shape · Columns
Replace via Mapping
Swaps values in one or more columns using a second table of from → to pairs, such as a code list turning 'NY' into 'New York'. Values with no match stay as they are, or fail the run if you choose.
Also known as: Mapping table, recode, translate codes
How it works
Wire the table to change into data and the code list into mapping. Under Columns to replace values in pick the data columns; Find (mapping column) and Replace with (mapping column) name the two mapping columns, or keep the default First column and Second column options to use the mapping's first and second column. A value equal to a find value becomes its replacement, compared as whole values; a replacement of null gives null. Anything else passes through unchanged unless Fail when a value has no match is ticked, in which case an unmatched value, a null included, stops the run and names the value. The run also fails if the find column holds a null or the same value twice. Rows and their order are kept one for one, and an empty mapping only warns.
Inputs and outputs
Inputs
data— Tablemapping— Table
Outputs
data— Table
Settings
The Attributes panel of Replace via Mapping, 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[]
fromColumn?: string
toColumn?: string
failOnUnmatched?: boolean
}input `data` = the table whose `columns` change; input `mapping` = from → to pairs (fromColumn / toColumn; empty = the mapping's first / second column). A value equal to a from value becomes its to value (a NULL to gives NULL); unmatched values pass through unless failOnUnmatched. Fails on a NULL or repeated from value. Rows and row order are kept.
Example
Orders carry two-letter state codes and the report wants names. Wire a states table with columns code and name into mapping, pick ship_state and bill_state, leave the mapping columns blank, and tick Fail when a value has no match to catch a typo in the data.