OpenBI Docs Buy

List.Difference

The items of one list that a second list does not take away, one for one.

Group: List. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

List.Difference(list1 as list, list2 as list, optional equationCriteria as any) as list
ParameterTypeDescription
list1listThe list to take from.
list2listThe values to take away.
equationCriteriaany
optional
How two values count as equal: a comparer or a key function.

Returns

list. What is left of list1, in its order.

Remarks

  • Each value of list2 takes away one matching item: a value that list1 holds twice and list2 once is left once. List.RemoveItems removes every occurrence.

Examples

Products not yet shipped

List.Difference({"Coffee", "Tea", "Milk", "Juice"}, {"Tea", "Juice"})
{"Coffee", "Milk"}

One of two teas shipped

List.Difference({"Tea", "Tea", "Milk"}, {"Tea"})
{"Tea", "Milk"}

List.RemoveItems, List.Intersect, List.Union.

Last updated · OpenBI Studio 0.3.79