How does the SUMX function (DAX) work?

The SUMX function (DAX) returns the sum of an expression evaluated for each row in a table.

SUMX Formula Syntax

SUMX(
<table>, <expression>
)

How do you use the SUMX function?

It works through a table, row by row to complete the evaluation after applying all filters. SUMX() has awareness of rows in a table, and hence can reference the intersection of each row with any columns in the table. SUMX() can operate over a single column but can also operate over multiple columns too – because it has the ability to work row by row.

Related Support Forum Posts

SUMX not calculating correctly
DATEADD within SUMX returning 0 or blank
Problem With SUMX With IF

Considerations when using the SUMX function

The SUMX function takes as its first argument a table, or an expression that returns a table. The second argument is a column that contains the numbers you want to sum, or an expression that evaluates to a column.

Only the numbers in the column are counted. Blanks, logical values, and text are ignored.

Formula examples using theSUMX function

=SUMX(FILTER(InternetSales, InternetSales[SalesTerritoryID]=5),[Freight])

SUMX = SUMX(Sales,Sales[Qty] * Sales[Price Per Unit])

=SUMX( FactInternetSales, FactInternetSales[SalesAmount]-FactInternetSales[TotalProductCost] )

DOWNLOAD

Download our comprehensive DAX Formula Reference Guide as perfect companion as you learn how to use DAX formulas within Power BI.