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>)
ArgumentRequiredDescription
tableRequiredThe table (or list of values) to go through.
expressionRequiredThe 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])
SegmentAvg per Country
Channel Partners360,118.73
Enterprise3,922,338.88
Government10,500,852.13
Midmarket476,376.61
Small Business8,485,583.70
Total23,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