List.AllTrue
Returns true only if every item in a list of logical values is true.
List.AllTrue(list)Returns: A logical value, true or false.
What it does
List.AllTrue answers "do all of the items pass?" It returns true only when every item in a list of true and false results is true. Use it as a pass or fail gate: if one item fails, the whole check fails.
Syntax and arguments
list: a list of logical values. Turn the items into true or false first with List.Transform.
Example
Every invoice in a batch must carry a valid tax code before the batch is posted. The check should pass only if all of them do.
let
TaxCodes = {"STD", "EXEMPT", "STD", "ZERO"},
ValidCodes = {"STD", "EXEMPT", "ZERO"},
AllValid = List.AllTrue(List.Transform(TaxCodes, each List.Contains(ValidCodes, _)))
in
AllValid
Every code in the list is in the valid set, so AllValid is true and the batch can move on. If one code were misspelled, the result would be false.
Example: a second, different use
Checking that every month in a 12-month schedule has a positive amount, before the schedule is loaded to the planning model.
Things to watch
- An empty list gives true, because nothing failed. Confirm the list has items with List.Count before you rely on the result.
- It does not tell you which item failed. For that, use List.Select on the same test.
- Keep the test strict and visible. A gate that is hard to read will be turned off the first time it fails.
- Combine with List.AnyTrue when you want both "all pass" and "any fail" wording in a report.
In business terms
Completeness and validity gates in data loads, pre-posting checks and reconciliation pass or fail flags use this pattern. An auditor can read the rule and see exactly what must hold.