Remove columns by name in Power Query

How removing columns by name works in Power Query, when to use an explicit list or a name pattern, and what breaks when source columns change.

Removing columns by name is one of the most common cleanup steps in Power Query. In Excel and Power BI you can do it by clicking column headers, but the underlying step always refers to columns by their text names. This review explains what that step changes, how to target columns by exact name or by a name pattern, and where the approach becomes fragile once a query is shared or the source data changes.

Is removing columns by name the right approach?

For most cleanup work, yes. You name the columns you don't want, and every refresh drops them again without manual effort. The main tradeoff is that names are matched as exact text. If the source renames or drops a listed column, the step fails by default. If the source adds new unwanted columns, they pass through untouched. An explicit, hard-coded list is the better choice when the set of columns is small and stable, or when other people need to audit the query. A pattern-based list built from the current column names is the better choice when unwanted columns follow a naming convention but their exact names or count vary.

  • Use an explicit list of names when the source schema rarely changes and readability for reviewers matters.
  • Use Remove Other Columns (keep by name) when you know what you need and want new, unexpected columns excluded automatically.
  • Use a pattern built with Table.ColumnNames and List.Select when unwanted columns share a prefix, suffix or substring.
  • Add MissingField.Ignore when a listed column may legitimately be absent and a refresh error would be worse than silently skipping it.

What the step actually changes

The step removes columns from the table that the query outputs. It does not edit the source file, worksheet or database. The removal is recorded as a step in the Applied Steps pane and re-applied on every refresh, so you can reverse it by deleting or editing that step. In Power BI this differs from hiding a column in the model or report view. A hidden column is still loaded into the model, while a column removed in Power Query is never loaded.

The phrase "remove columns" covers two commands that behave differently. Remove Columns generates Table.RemoveColumns, which drops the columns you name and keeps everything else. Remove Other Columns generates Table.SelectColumns, which keeps only the columns you name and drops everything else. Both work by name, but they react in opposite ways when a new column appears in the source. The first lets it through; the second excludes it.

= Table.RemoveColumns(Source, {"Notes", "Internal ID"})

By default, if either name in the list is not found, the step raises an error and the refresh stops. Table.RemoveColumns accepts an optional third argument that controls this. MissingField.Ignore skips names that don't exist instead of failing. It makes the query more tolerant, but it can also hide a real problem, such as a column that was renamed upstream and is now slipping through under its new name.

= Table.RemoveColumns(Source, {"Notes", "Internal ID"}, MissingField.Ignore)

Removing columns that match a name pattern

Sometimes you know a naming rule but not the exact list, for example every column starting with "Temp". In that case you can build the list at refresh time. Table.ColumnNames returns the current column names as a list, and List.Select filters that list with a condition. The filtered list is then passed to Table.RemoveColumns.

let
    Source = ...,
    ToRemove = List.Select(Table.ColumnNames(Source), each Text.StartsWith(_, "Temp")),
    Result = Table.RemoveColumns(Source, ToRemove)
in
    Result

As an illustration, a table with the columns ID, Name, Temp_A and Temp_B would come out of this query with only ID and Name. This example shows the intended logic and is not a recorded test result. Text comparisons in M are case-sensitive by default, so a column named "temp_C" would not match "Temp". Text.StartsWith, Text.EndsWith and Text.Contains accept an optional comparer for case-insensitive matching. Because the list is built from names that currently exist, the pattern approach does not raise missing-column errors. That comes at a cost: if the rule matches nothing, the step silently removes nothing.

ToRemove = List.Select(Table.ColumnNames(Source), each Text.StartsWith(_, "temp", Comparer.OrdinalIgnoreCase))

Will the query keep working after sharing or reuse?

A query keeps working elsewhere only if the same column names exist upstream. Copying the M code into another workbook or report carries the names with it. The code will error, or silently skip columns under MissingField.Ignore, if the new source names them differently. Small differences count: case, trailing spaces and changed separators all prevent a match. Each step also refers to the previous step by name, such as Source in the examples above, so pasted code may need its step references adjusted.

Readability differs between the two approaches. An explicit list documents itself: anyone reading the step can see exactly which columns are dropped, and searching the query text for a column name will find it. A pattern is shorter and adapts to change, but the affected columns can only be identified by running it against current data. Renaming the step to something descriptive in Applied Steps helps collaborators either way. No documentation or tests were supplied on how the Power Query editor or the resulting step names behave with screen readers or other assistive technology, so this review makes no claim about accessibility.

Gaps in this review

The behavior described here is based on documented M functions and the standard ribbon commands. No hands-on tests, version comparisons or performance measurements were provided. Version-specific differences between Excel and Power BI, refresh performance on large sources, and whether a removal step folds back to a database source have not been verified here. If those matter for your use, check them in your own environment, for example by inspecting the native query on a database source.