List.MatchesAll checks every value in a list against a condition and returns true only if all of them satisfy it. Available in Excel (Power Query), Power BI Desktop, and Power BI Service.
If you want a single yes/no answer to whether every item in a list passes a rule, such as “are all scores at least 50”, this is the function to use.
Syntax of List.MatchesAll Function
List.MatchesAll(list as list, condition as function) as logical
where
list(required, list). The list whose values you want to check.condition(required, function). The test applied to each value, usually written as aneachexpression with_standing in for the current item, for exampleeach _ > 0.
Returns: a logical value, either true or false.
In plain terms, it returns true if every item in the list satisfies the condition, and false as soon as one item fails.
Example 1: Check that every number is positive
Test whether all the numbers in a list are greater than 0.
List.MatchesAll({2,4,6},each _ > 0)
Result: true
Every value clears the rule, so the function returns true.
Example 2: One failing item makes the whole result false
List.MatchesAll({2,4,-6},each _ > 0)
Result: false
-6 does not satisfy each _ > 0, and a single failure is enough to make the result false.
Example 3: Check that every text value starts with a letter
The condition can be any test, not just a number comparison. Here it checks that each name starts with A.
List.MatchesAll({"Apex","Atlas","Aurora"},each Text.StartsWith(_,"A"))
Result: true
All three names begin with A, so the function returns true.
Example 4: Check that a whole column passes a rule
The most useful case is testing a table column. Say you have a Results query with a Candidate and a Score column, and you want to know whether every candidate scored at least 50.
Here is the starting data:
| Candidate | Score |
|---|---|
| Rohan | 74 |
| Mira | 88 |
| Tomas | 51 |
| Lena | 67 |
Pull the Score column into List.MatchesAll:
let
Source = Excel.CurrentWorkbook(){[Name="Results"]}[Content],
AllPass = List.MatchesAll(Source[Score],each _ >= 50)
in
AllPass
Result: true
Every score is 50 or higher, so the column passes and the function returns a single true. Because the result is one boolean and not a table, there is no result grid here.
Example 5: An empty list returns true
List.MatchesAll({},each _ > 0)
Result: true
With no items in the list, there is nothing that can break the rule, so the result is true. This is known as vacuous truth.
Things to keep in mind with List.MatchesAll
- The second argument is a function, not a list of booleans.
List.MatchesAllapplies theeachcondition to each item itself. If you already have a list of pre-computedtrue/falsevalues, useList.AllTrueinstead, which takes those booleans directly with no condition. - An empty list returns
true. With nothing to violate the condition, the result istrue(Example 5). Guard against this if an empty list should really count as a failure in your logic. - It is the AND-counterpart of
List.MatchesAny.List.MatchesAllneeds every item to pass;List.MatchesAnyreturnstrueas soon as one item passes. - The condition must be callable. Passing a literal value instead of a function (for example a number or a plain boolean) raises an error rather than being coerced.
_refers to the whole item. For a flat list it iseach _ > 0. For a list of records you reach a field witheach [Field] > 0instead.- It only tells you pass or fail, not which item failed. When you need the offending rows, filter them with
Table.SelectRows, then count the result withList.Countto see how many fell short.
Common questions about List.MatchesAll
What is the difference between List.MatchesAll, List.AllTrue, and List.MatchesAny?
List.MatchesAll(list, condition) applies a condition function and returns true if every item passes. List.MatchesAny(list, condition) does the same but returns true if at least one item passes. List.AllTrue(list) takes a list that already holds true/false values and returns true if all of them are true. So MatchesAll and MatchesAny take a condition, while AllTrue takes ready-made booleans.
How do I check that a whole column passes a rule?
Feed the column into the function with List.MatchesAll(Source[ColumnName],each _ >= threshold). It returns a single boolean for the entire column, which is handy for data-quality gates like “are all scores at least 50” (Example 4). If instead you want to know whether a specific value appears in the column, use List.Contains.
List of All Power Query Functions
Related Power Query Functions / Articles: