List.MatchesAny
ListReturns true if the condition function returns true for at least one item in the list.
Syntax
List.MatchesAny(list as list, condition as function) as logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
list | list | Yes | The list to test. |
condition | function | Yes | A function that takes a list item and returns a logical value. |
Return Value
logical — True if the condition returns true for at least one item; false if no items satisfy the condition.
Remarks
List.MatchesAny applies a condition (predicate) function to each item in a list and returns true as soon as any item satisfies the condition. It is the list equivalent of the existential quantifier — "there exists at least one item for which the condition holds."
Unlike List.AnyTrue, which expects a pre-built list of logical values, List.MatchesAny accepts any list and evaluates the predicate inline. This makes it the cleaner choice when working directly with data: List.MatchesAny(Products[InStock], each _ = true) is more readable than wrapping List.Transform.
An empty list returns false. The function short-circuits as soon as a passing item is found, so it can be efficient on large lists when an early match is likely. For simple equality checks (does any item equal this value?), List.Contains is more idiomatic. Use List.MatchesAny for composite or calculated conditions that go beyond simple equality.
Examples
Example 1: Check if any number exceeds a threshold
List.MatchesAny({10, 25, 5, 8}, each _ > 20)Result | |
|---|---|
| 1 | TRUE |
Example 3: Check if any product is out of stock
let
StockLevels = {100, 0, 45, 230, 0},
HasOutOfStock = List.MatchesAny(StockLevels, each _ = 0)
in
HasOutOfStockThe final output — checks whether any stock level equals zero, returning true because two products have no stock.
Result | |
|---|---|
| 1 | TRUE |