List.RemoveMatchingItems
A list without any item that matches one of a second list, optionally by your own rule of equality.
Group: List. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
List.RemoveMatchingItems(list1 as list, list2 as list, optional equationCriteria as any) as list
| Parameter | Type | Description |
|---|---|---|
list1 | list | The list to remove from. |
list2 | list | The values to remove. |
equationCriteria | any optional | How two values count as equal: a comparer or a key function. |
Returns
list. The items of list1 that match none of list2.
Examples
Remove every tea
List.RemoveMatchingItems({"Coffee", "Tea", "Milk", "Tea"}, {"Tea"})
{"Coffee", "Milk"}
Ignoring capitals
List.RemoveMatchingItems({"Coffee", "tea", "Milk"}, {"TEA"}, Comparer.OrdinalIgnoreCase)
{"Coffee", "Milk"}