Table.RemoveColumns

Updated on

Table.RemoveColumns is a Power Query M function that removes specified columns from a table. The function returns a new table without the specified columns, and can handle missing columns based on an optional parameter.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Table.RemoveColumns(
   table as table,
   columns as any,
   optional missingField as nullable number,
) as table
Argument Attribute Description
table
columns
missingField optional The MissingField.Type determines the function’s reaction to operations on missing columns. When omitted, it uses MissingField.Error and generates an error for missing columns. Alternatives include MissingField.UseNull, substituting null for missing columns, and MissingField.Ignore, which ignores missing columns.

Description

Table.RemoveColumns removes specified columns. It deletes columns from table. If a column doesn’t exist, an error is raised unless missingField specifies an alternative behavior.

Examples

Remove column [Phone] from the table.

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

Try to remove a non-existent column from the table.

// Output: [Expression.Error] The column 'Address' of the table wasn't found.
Table.RemoveColumns( 
    Table.FromRecords( {[CustomerID = 1, Name = "Bob", Phone = "123-4567"]} ),
    "Address"
 )

Other functions related to Table.RemoveColumns are:

BI Gorilla Blog

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/table-removecolumns