Table.DuplicateColumn
TableDuplicates a column in a table with a new name.
Syntax
Table.DuplicateColumn(table as table, columnName as text, newColumnName as text, optional columnType as nullable type) as tableParameters
| Name | Type | Required | Description |
|---|---|---|---|
table | table | Yes | The input table. |
columnName | text | Yes | The name of the column to duplicate. |
newColumnName | text | Yes | The name of the new duplicate column. |
columnType | type | No | Optional type for the new column. |
Return Value
table — The input table with a new column that is a copy of the specified column.
Remarks
Table.DuplicateColumn creates a copy of an existing column with a new name. This is useful when you want to transform a column but also keep the original values — duplicate first, then transform the copy.
The new column is appended to the end of the table. Use Table.ReorderColumns if you need it in a specific position.
Examples
Example 1: Duplicate a column for transformation
Table.SelectColumns(
Table.DuplicateColumn(Table.FirstN(Sales, 3), "Product", "OriginalProduct"),
{"OrderID", "Product", "OriginalProduct"}
)Result
OrderID | Product | OriginalProduct | |
|---|---|---|---|
| 1 | 1 | Widget A | Widget A |
| 2 | 2 | Gadget B | Gadget B |
| 3 | 3 | Widget C | Widget C |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks