List.AllTrue Function (Power Query M)

List.AllTrue checks a list of logical values and returns true only when every one of them is true. Available in Excel (Power Query), Power BI Desktop, and Power BI Service.

If you have several conditions and you want a single true or false that says whether all of them hold, this is the function you reach for.

Syntax of List.AllTrue Function

List.AllTrue(list as list) as logical

where

  • list (required, list). A list of logical values, or expressions that each evaluate to a logical (true or false).

Returns: a logical value, either true or false. It is true only when every item in the list is true.

In plain terms, you hand it a list of conditions and it tells you whether all of them are satisfied.

Example 1: All values are already true

Start with the simplest case, a list of three true values.

List.AllTrue({true,true,true})

Result: true

Every item is true, so the function returns true.

Example 2: Conditions that all hold

The list usually holds comparisons rather than bare true values. Here all three comparisons are true.

List.AllTrue({10>5,3>1,8>2})

Result: true

10>5, 3>1, and 8>2 each evaluate to true, so the result is true.

Example 3: One condition fails

Change the last comparison so it is false.

List.AllTrue({10>5,3>1,8<2})

Result: false

8<2 is false, and a single false is enough to make the whole result false.

Example 4: Filter rows that pass all conditions

The most useful home for List.AllTrue is inside Table.SelectRows, where you keep only the rows that satisfy several conditions at once.

Say you have an Orders query with Product, Qty, Price, and Status columns.

You want to keep only the rows where Qty is above 0, Price is above 0, and Status is Active.

Here is the starting data:

ProductQtyPriceStatus
Notebook124Active
Stapler09Active
Marker302Inactive
Folder83Active
Eraser251Active
Tape50Active

Now wrap the three conditions in List.AllTrue inside Table.SelectRows:

let
Source = Excel.CurrentWorkbook(){[Name="Orders"]}[Content],
Filtered = Table.SelectRows(Source,each List.AllTrue({[Qty]>0,[Price]>0,[Status]="Active"}))
in
Filtered

This keeps only the rows where all three conditions are true.

The result has three rows:

ProductQtyPriceStatus
Notebook124Active
Folder83Active
Eraser251Active

Stapler is dropped for Qty of 0, Marker for being Inactive, and Tape for a Price of 0.

Example 5: An empty list returns true

This is the one result that surprises people. Pass an empty list and List.AllTrue does not error or return false.

List.AllTrue({})

Result: true

With no items in the list, there is nothing that can be false, so “all are true” is technically satisfied. This is known as vacuous truth.

Things to keep in mind with List.AllTrue

  • An empty list returns true. List.AllTrue({}) is true because there is no item that could be false (Example 5). If your list is built dynamically and can come out empty, this can let rows through that you meant to block, so guard for it.
  • Every item must be a logical value. Pass a number, text, or null where a boolean is expected and it throws a type error like We cannot convert the value 1 to type Logical. It does not coerce 1/0 or "true" into booleans, so wrap each item in a comparison.
  • List.AnyTrue is the OR counterpart. List.AllTrue is true only when every condition holds (AND logic); List.AnyTrue is true when at least one condition holds (OR logic). Reach for whichever matches your test.
  • It is at its best inside Table.SelectRows. For multi-condition row filters, each List.AllTrue({[Qty]>0,[Price]>0,[Status]="Active"}) reads more cleanly than a long and ... and ... chain and is easy to extend when you add another condition.

Common questions about List.AllTrue

Is List.AllTrue any different from chaining the conditions with and?

Functionally no. List.AllTrue({a,b,c}) gives the same result as a and b and c. It pays off when there are many conditions or the conditions are generated as a list (for example with List.Transform), because you avoid a long and ... and ... chain and the list stays easy to extend.

What is the difference between List.AllTrue and List.AnyTrue?

List.AllTrue returns true only if every expression is true (AND logic). List.AnyTrue returns true if at least one expression is true (OR logic). They also differ on empty lists: List.AllTrue({}) is true, while List.AnyTrue({}) is false.

List of All Power Query Functions

Related Power Query Functions / Articles:

I am a huge fan of Microsoft Excel and love sharing my knowledge through articles and tutorials. I work as a business analyst and use Microsoft Excel extensively in my daily tasks. My aim is to help you unleash the full potential of Excel and become a data-slaying wizard yourself.