List.RemoveItems

List

Removes all occurrences of specified values from a list.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

List.RemoveItems(list1 as list, list2 as list) as list

Parameters

NameTypeRequiredDescription
list1listYesThe original list.
list2listYesA list of values to remove from the first list.

Return Value

listA list with all occurrences of the specified values removed.

Remarks

List.RemoveItems removes all occurrences of specific values from a list. A common pattern is combining Table.ColumnNames with List.RemoveItems to get all column names except certain ones, then passing the result to Table.SelectColumns or Table.UnpivotOtherColumns.

Examples

Example 1: Get columns except specific ones

let
    AllCols = Table.ColumnNames(Sales),
    Excluded = List.RemoveItems(AllCols, {"OrderDate", "Region"})
in
    #table({"ColumnName"}, List.Transform(Excluded, each {_}))
Result
ColumnName
1OrderID
2CustomerName
3Product
4Category
5UnitPrice
6Quantity

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks