<!-- https://learnsql.cpetoday.com/functions/m/list-average -->
# List.Average

Language: Power Query M
Category: List: summarize
Syntax: List.Average(list, optional precision)
Summary: Returns the mean (average) of the numbers in a list.
Returns: A number, the sum of the items divided by how many there are.
Level: Beginner
Related: List.Sum, List.Median, List.Count, List.RemoveNulls, List.Min

## What it does
List.Average adds the numbers in a list and divides by how many there are. It is the M version of AVERAGE. Use it for an average invoice size, the average days to pay, or the average monthly sales for a customer over a period. Be careful with nulls, because they affect the count.

## Syntax and arguments
- `list`: the numbers to average.
- `precision` (optional): the same choice as List.Sum. `Precision.Decimal` suits money.

## Example
A collections team wants the average days taken to pay, for a set of paid invoices, to compare against the stated terms. Some invoices have not been paid yet and their day counts are blank.

```powerquery
let
    DaysToPay = {12, 30, null, 45, 18},
    Paid = List.RemoveNulls(DaysToPay),
    AverageDays = List.Average(Paid, Precision.Decimal)
in
    AverageDays
```

`Paid` drops the blank entry, so the average is taken over the four paid invoices: (12 + 30 + 45 + 18) divided by 4, which is 26.25. Leaving the blank in would make it unclear how many invoices the average covers, so removing nulls first is the safe habit.

## Example: a second, different use
An average unit price is total cost divided by total quantity, not the simple average of the unit prices. Use List.Sum on each list, then divide the two totals.

## Things to watch
- A simple average of percentages or unit prices is often wrong. A weighted average (total divided by total) is what most finance questions need.
- Blank rows are a common trap. Decide whether a blank means zero, not applicable or unknown, and handle it deliberately.
- An empty list has no average. Check for it with List.Count before you divide.
- Averages of skewed data, such as invoice sizes with a few very large items, can mislead. Pair the average with List.Median.

## In business terms
Average days sales outstanding, average invoice size, average cost per hour and average monthly spend per vendor are common finance measures. State which items were included, so the average can be reproduced.
