Table.RemoveColumns

Syntax

Table.RemoveColumns(table as table, columns as any, optional missingField as nullable number) as table

About

Removes the specified columns from the table provided. If the column doesn't exist, an exception is thrown unless the optional parameter missingField specifies an alternative (eg. MissingField.UseNull or MissingField.Ignore).

Example 1

Remove column [Phone] from the table.

Usage

Table.RemoveColumns(
    Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
    "Phone"

Output

Table.FromRecords({[CustomerID = 1, Name = "Bob"]})

Example 2

Remove column [Address] from the table. Throws an error if it doesn't exist.

Usage

Table.RemoveColumns(
    Table.FromRecords({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
    "Address"
)

Output

[Expression.Error] The field 'Address' of the record was not found.