List.AllTrue

D

T

The M Code Behind the Power Query M function List.AllTrue

In this article, we will take a closer look at the M code behind the Power Query M function List.AllTrue. This function is used to determine if all the values in a list are true. Let’s dive in!

Syntax

Before we dive into the M code, let’s look at the syntax of the List.AllTrue function. The function takes a single argument, which is a list of values. It returns a Boolean value that indicates whether all the values in the list are true.

Here’s the syntax of the List.AllTrue function:


List.AllTrue(list as list) as logical


M Code Explanation

Now that we know the syntax of the List.AllTrue function, let's take a closer look at the M code behind it.

The M code for the List.AllTrue function is actually quite simple. Here's the code:


(list) => List.AllTrue(list)


The code consists of a lambda expression that takes a single argument, which is a list of values. The lambda expression then calls the List.AllTrue function, passing in the list of values as an argument. The List.AllTrue function returns a Boolean value that indicates whether all the values in the list are true. The lambda expression then returns this Boolean value as the result of the function.

How List.AllTrue Works

Now that we know what the M code behind the List.AllTrue function looks like, let's take a closer look at how the function works.

The List.AllTrue function works by iterating through all the values in the input list. If any of the values are false, the function returns false. If all the values in the list are true, the function returns true.

Here's an example of how the List.AllTrue function works:


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

List.AllTrue({true, false, true}) // returns false


In the first example, all the values in the input list are true, so the function returns true. In the second example, one of the values in the input list is false, so the function returns false.

In this article, we took a closer look at the M code behind the Power Query M function List.AllTrue. We learned that the function works by iterating through all the values in the input list and returning true if all the values are true, and false otherwise. We also saw that the M code behind the function is quite simple, consisting of a lambda expression that calls the List.AllTrue function. Overall, the List.AllTrue function is a useful tool for checking whether all the values in a list are true, and it showcases the power and flexibility of the M language in Power Query.

Power Query and M Training Courses by G Com Solutions (0800 998 9248)

Upcoming Courses

Contact Us

    Subject

    Your Name (required)

    Company/Organisation

    Email (required)

    Telephone

    Training Course(s)

    Your Message

    Upload Example Document(s) (Zip multiple files)