Back to All DAX Concepts
Iterators

DAX SUMX Function

Calculate expressions row-by-row before summing up results.

Syntax Definition:
SUMX( Table, Expression )

Overview

SUMX iterates over a table, creates a row context for each individual row, computes an expression, and sums the results.

Architectural Deep Dive

SUMX is an iterator function (indicated by the 'X' suffix). It solves the common scenario where an analytical metric cannot be calculated as a single physical column, such as multiplying quantity by unit price across related dimension tables.

Canonical Pattern Example:

Total Sales Margin = 
SUMX(
    Sales,
    Sales[Revenue] - Sales[Cost]
)

Common Anti-Patterns & Mistakes to Avoid

  • Using SUMX(Table, Table[Column]) when simple SUM(Table[Column]) would be much faster.
  • Referencing a measure inside SUMX without realizing it triggers Context Transition.
  • Iterating over large fact tables when a pre-aggregated dimension could be used.
Interactive Challenge

Put DAX SUMX Function into practice

Solve "Calculate Total Margin with SUMX" in our interactive Monaco editor with live dataset verification.