DAX AVERAGEX function
Calculates an expression for each row of a table, then averages the results.
AVERAGEX averages per row or per group. "Average sales per country" is AVERAGEX over the list of countries, not AVERAGE over sales rows.
Syntax
AVERAGEX(<table>, <expression>)| Argument | Required | Description |
|---|---|---|
| table | Required | The table (or list of values) to go through. |
| expression | Required | The calculation for each row. |
Returns: A decimal number.
Examples
Calculated on the free practice data (table financials), with [Total Sales] = SUM(financials[Sales]) and [Total Profit] = SUM(financials[Profit]).
1. Average sales per country
Avg per Country = AVERAGEX(VALUES(financials[Country]), [Total Sales])Result: 23,745,270.05
Total Sales for each of the five countries, then the average of those five numbers.
2. Average sales per country, by segment
Avg per Country = AVERAGEX(VALUES(financials[Country]), [Total Sales])| Segment | Avg per Country |
|---|---|
| Channel Partners | 360,118.73 |
| Enterprise | 3,922,338.88 |
| Government | 10,500,852.13 |
| Midmarket | 476,376.61 |
| Small Business | 8,485,583.70 |
| Total | 23,745,270.05 |
For each segment, the average over its countries.
Good to know
- A measure inside AVERAGEX gets the current row as a filter (context transition), which is what makes per-group averages work.
Related functions
Official reference: AVERAGEX function on Microsoft Learn