<!-- https://learnsql.cpetoday.com/functions/m/table-removecolumns -->
# Table.RemoveColumns

Language: Power Query M
Category: Table: columns
Syntax: Table.RemoveColumns(table as table, columns as any, optional missingField as nullable number) as table
Summary: Deletes one or more columns from a table.
Returns: A table without the named columns.
Level: Beginner
Related: Table.SelectColumns, Table.RenameColumns, Table.ReorderColumns, Table.SelectRows

## 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
- **table**: the table to change. Required.
- **columns**: a column name in quotes, or a list of names in braces. Required.
- **missingField**: what to do when a named column does not exist. The default is an error. `MissingField.Ignore` skips missing names quietly, which helps when an export sometimes omits a column.

## 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.

```powerquery
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.

```powerquery
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
- Removing a column is final for this query. Add it back by editing the query, not by undoing a later step.
- A misspelled name is an error unless you use MissingField.Ignore. The error is a good thing: it means the name is wrong.
- New columns added to the source later are kept, because you only named the ones to remove. If you want only a fixed set, use Table.SelectColumns instead.
- Query folding: removing columns usually folds to a shorter SELECT list, so it is a cheap early step.

## 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.
