OpenBI Docs Buy

Table.DuplicateColumn

Copies a column into a new one with another name, at the end of the table.

Group: Table. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

Table.DuplicateColumn(table as table, columnName as text, newColumnName as text, optional columnType as nullable type) as table
ParameterTypeDescription
tabletableThe table with the column.
columnNametextThe column to copy.
newColumnNametextThe copy's name.
columnTypenullable type
optional
The copy's type; the column's own type when left out.

Returns

table. The table with the copy as its last column.

Remarks

  • Handy before a step that changes a column, such as a split, when the original is still needed.

Examples

Keep the original before changing it

let
    Lines = #table({"Product", "Price", "Units"}, {{"Chair", 50, 4}, {"Desk", 120, 1}, {"Lamp", 30, 6}}),
    Copied = Table.DuplicateColumn(Lines, "Product", "Product code")
in
    Table.TransformColumns(Copied, {"Product code", Text.Upper})
ProductPriceUnitsProduct code
Chair504CHAIR
Desk1201DESK
Lamp306LAMP

Table.AddColumn, Table.TransformColumns, Table.RenameColumns.

Last updated · OpenBI Studio 0.3.79