Add Column
Add Column
Section titled “Add Column”Type: add-column · Package: DataTable Activities v1.0.5 · Output: DataTable
Adds a new calculated column to a DataTable: for each row, it evaluates an expression and stores the result in the column. Use it to derive data from existing data — a total with tax, a category, an “overdue” flag, a combined text.
How it works
Section titled “How it works”Copies the table (columns and rows) and appends the column at the end. Then it walks the rows evaluating the value expression. The row’s columns are available as variables inside that expression: you can reference them directly by name, together with the flow’s variables. It returns the new table; the original does not change.
- The new column accepts any type of value (
object); each cell stores whatever the expression returns. If the expression returnsnull, the cell is left empty (DBNull). - Inside the expression, an empty cell arrives as
null. - If
valueis a fixed value (for example"Pending"), every row gets that same value.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
table | DataTable | — | The DataTable to extend. |
column | string | — | Name of the new column. It must not already exist in the table. |
value | object | — | Expression evaluated on each row. The row’s columns are injected as variables with their names. |
Optional parameters
Section titled “Optional parameters”None.
Output
Section titled “Output”Returns a new DataTable with all the columns and rows of the original plus the added column at the end.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'table' must be a DataTable. | table does not evaluate to a DataTable. |
'column' is required. | The new column name is missing. |
A column named '…' already belongs to this DataTable. | A column with that name already exists (.NET message). Pick another name or remove the existing one with Drop Column. |
| Expression error | The value expression failed on some row (for example, converting an empty cell). Use num(...) and str(...) to handle empty cells. |
Example
Section titled “Example”Add a TotalWithTax column computed from the Total column:
Add Column table = invoices column = "TotalWithTax" value = num(Total) * 1.19 → output: withTaxAggregate Column table = withTax column = "TotalWithTax" operation = sum → output: totalWithTaxHere Total refers to the Total column of the current row. Wrap it in num(...) or str(...) to handle the cell value safely.
Add Column table = customers column = "Greeting" value = "Dear " + str(Name) → output: withGreetingRelated activities
Section titled “Related activities”- Drop Column — remove columns.
- Rename Column — rename a column.
- Aggregate Column — summarize a numeric column.