Downloads
Power Query MTable: columnsBeginner

Table.RemoveColumns

Deletes one or more columns from a table.

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

Returns: A table without the named columns.

What it does

Table.RemoveColumns deletes the columns you name and keeps everything else. It removes columns in this query only. The source file or database is not changed. Use it to drop helper columns, internal notes or personal data that should not reach the report.

Syntax and arguments

Example

A general ledger export contains an internal column, Created By, and a free-text Notes column that should not go into the management report.

let
    Source = Excel.CurrentWorkbook(){[Name = "GLExport"]}[Content],
    ForReport = Table.RemoveColumns(Source, {"Created By", "Notes"}, MissingField.Ignore)
in
    ForReport

The two columns are removed. Because MissingField.Ignore is set, the query still runs next month if the export no longer has the Notes column.

Example: a second, different use

Early in a database query, drop wide columns that the report does not need. The orders table has two date columns that are not used.

let
    Source = Sql.Database("learnsql.cpetoday.com,1433", "classicmodels"),
    Orders = Source{[Schema = "classicmodels", Item = "orders"]}[Data],
    Slim = Table.RemoveColumns(Orders, {"requiredDate", "shippedDate"})
in
    Slim

Things to watch

In business terms

Removing internal and personal fields before a table is shared keeps reports focused and reduces the chance of sending data that should not leave the team.

Related functions

All Power Query M functions · View as Markdown · M basics