List.ContainsAll
ListReturns true if a list contains all of the values in another list.
Syntax
List.ContainsAll(list as list, values as list, optional equationCriteria as any) as logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
list | list | Yes | The list to search. |
values | list | Yes | The list of values that must all be present. |
equationCriteria | any | No | A comparer function for custom equality testing. |
Return Value
logical — true if every value from the second list is found in the first list.
Remarks
List.ContainsAll returns true only if every value in the second list appears in the first list. A single missing value causes it to return false. For a looser check that requires just one match, use List.ContainsAny.
The optional equationCriteria parameter accepts a comparer (such as Comparer.OrdinalIgnoreCase) for case-insensitive or culture-sensitive comparisons.
Examples
Example 1: Verify all required columns are present
Check whether a table has all of the columns needed for a downstream transformation.
let
RequiredColumns = {"OrderID", "CustomerID", "Amount", "Region"},
ActualColumns = Table.ColumnNames(Sales),
AllPresent = List.ContainsAll(ActualColumns, RequiredColumns)
in
#table({"AllColumnsPresent"}, {{AllPresent}})The final output — wraps the logical result in a single-row table labeled AllColumnsPresent.
AllColumnsPresent | |
|---|---|
| 1 | TRUE |
Example 2: Check for missing values
When not all values are present, the function returns false.
let
Source = {"a", "b", "c"},
CheckList = {"a", "b", "d"},
Result = List.ContainsAll(Source, CheckList)
in
ResultThe final output — returns false because "d" from CheckList is not found in Source.
Result | |
|---|---|
| 1 | FALSE |