DAX AVERAGEX Function

Get last date in the current context in DAX.

AVERAGEX is an iterator function in DAX that:

  • Iterates over a table
  • Evaluates an expression for each row
  • Returns the average of all evaluated values

It’s similar to SUMX, but instead of summing, it averages the result of the expression.

Syntax

AVERAGEX(<table>, <expression>)
  • <table>: A real or virtual table to iterate over
  • <expression>: An expression evaluated row-by-row

Example

Suppose you have a table Sales:

ProductQuantityUnitPrice
A210
B315
C120

You want the average revenue per transaction (Quantity * UnitPrice for each row).

DAX formula

AVERAGEX(Sales, Sales[Quantity] * Sales[UnitPrice])
  • Step-by-step:
RowCalculationResult
12 × 1020
23 × 1545
31 × 2020

Average = (20 + 45 + 20) / 3 = 28.33

Why Not Use AVERAGE?

The regular AVERAGE function only works on a single column — you can't use it to compute Quantity * UnitPrice.

AVERAGE(Sales[Quantity] * Sales[UnitPrice])
--  This will throw an error

You need AVERAGEX for expressions.

Real-world Use Cases for AVERAGEX

ScenarioExample Expression
Average revenue per transactionSales[Quantity] * Sales[UnitPrice]
Average discount givenOrders[DiscountAmount] / Orders[Total]
Average price of products in a filtered categoryWith FILTER(Products, ...), then Price
Average custom metric based on calculated columns/measuresAny row-based expression

Works with Virtual Tables

You can use AVERAGEX with DAX functions like FILTER, VALUES, or SUMMARIZE to create dynamic row sets:

AVERAGEX(
    FILTER(Sales, Sales[Quantity] > 1),
    Sales[Quantity] * Sales[UnitPrice]
)

This averages revenue only for rows with quantity > 1.

Summary

FeatureDescription
Function typeIterator
Iterates overA table (real or virtual)
EvaluatesAn expression row-by-row
ReturnsAverage of the evaluated values
Use caseRow-level average, especially with expressions
Compared to AVERAGEAVERAGE = simple column average, no expression support
No questions available.