Skip to main content

Table.DuplicateColumn

Duplicates a column with the specified name. Values and type are copied from the source column.

Syntax

Table.DuplicateColumn(
table as table,
columnName as text,
newColumnName as text,
optional columnType as type
) as table

Remarks

Duplicate the column named columnName to the table table. The values and type for the column newColumnName are copied from coulmn columnName.

Examples

Example #1

Duplicate the column "a" to a column named "copied column" in the table <code>({[a = 1, b = 2], [a = 3, b = 4]})</code>.

Table.DuplicateColumn(
Table.FromRecords({
[a = 1, b = 2],
[a = 3, b = 4]
}),
"a",
"copied column"
)

Result:

Table.FromRecords({
[a = 1, b = 2, #"copied column" = 1],
[a = 3, b = 4, #"copied column" = 3]
})

Category

Table.Column operations