List.Average

D

T

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

What is the List.Average Function?

The List.Average function is a Power Query M function that is used to calculate the average of a list of numbers. It takes a list of numbers as input and returns the average value of those numbers. The syntax of the List.Average function is as follows:


List.Average(list as list) as number


Here, `list` is the input list of numbers, and the function returns a `number` that represents the average value of the list.

How Does the List.Average Function Work?

The List.Average function works by first summing all the numbers in the input list and then dividing the sum by the number of items in the list. Here is the M code behind the List.Average function:


(list) => List.Sum(list) / List.Count(list)


As you can see, the function takes the input list as a parameter, sums the list using the List.Sum function, and divides the sum by the number of items in the list using the List.Count function.

Examples of Using the List.Average Function

Here are some examples of using the List.Average function to calculate the average of a list of numbers:

Example 1

Suppose we have the following list of numbers:


{1, 2, 3, 4, 5}


To calculate the average of this list, we can use the List.Average function as follows:


List.Average({1, 2, 3, 4, 5})


The result will be:


3


Example 2

Suppose we have the following list of numbers:


{10, 20, 30, 40, 50}


To calculate the average of this list, we can use the List.Average function as follows:


List.Average({10, 20, 30, 40, 50})


The result will be:


30


The List.Average function is a useful Power Query M function that can be used to calculate the average of a list of numbers. It works by summing all the numbers in the input list and then dividing the sum by the number of items in the list. By using this function, you can quickly and easily calculate the average of any list of numbers 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)