Skip to main content
< All Topics

DAX Library: SUMX Function

While SUM is a vertical aggregator, SUMX is an Iterator. It is the “workhorse” of DAX that allows you to perform complex, row-by-row logic across multiple columns before totaling the result.

✓ Expert Verified

This documentation has been written and reviewed by our Power BI Experts to ensure technical accuracy and compatibility with the 2026 Power BI Desktop update.


1. Description: What does it do?

SUMX tells Power BI to “iterate” (loop) through a table, row by row. At each row, it performs a specific calculation (the expression) and stores that result in temporary memory. Once it reaches the end of the table, it adds all those temporary results together.

The Syntax:

SUMX(<table>, <expression>)


2. Official Syntax & Primary Example

Example 1: The “Classic” Multiplication (Price × Quantity)

In many raw datasets, you have the price and the quantity, but not the total line value. SUMX calculates the total for each row first.

Code snippet

Calculated Revenue = 
SUMX(
    Sales, 
    Sales[UnitPrice] * Sales[Quantity]
)

3. Professional Use-Case Examples

To build your authority, show your readers how SUMX solves real-world business problems beyond simple math:

A. Finance: Tax-Inclusive Reporting

If your tax rate varies by product category, you can’t just sum the tax column. You need to calculate it per row.

Code snippet

Total Revenue Inc Tax = 
SUMX(
    Sales, 
    Sales[NetPrice] * (1 + Sales[TaxRate])
)

B. Logistics: Weighted Shipping Costs

Use this to calculate total shipping costs based on weight and a per-kg rate that might be stored in a related table.

Code snippet

Total Shipping Cost = 
SUMX(
    Orders, 
    Orders[Weight_KG] * RELATED(CarrierRates[RatePerKG])
)

C. Retail: Potential Revenue (Handling Discounts)

Calculate what your revenue would have been if no discounts were applied.

Code snippet

Gross Potential Sales = 
SUMX(
    Sales, 
    Sales[Quantity] * RELATED(Products[ListPrice])
)

D. HR/Payroll: Total Overtime Pay

Calculate pay for only the hours worked above the standard 40-hour threshold.

Code snippet

Total OT Pay = 
SUMX(
    Timesheets, 
    IF(Timesheets[Hours] > 40, (Timesheets[Hours] - 40) * Timesheets[OT_Rate], 0)
)

4. Common Mistakes & How to Fix Them

MistakeWhy it happensThe Fix
Performance DragUsing SUMX on a table with 50+ million rows for a simple sum.If the calculation can be done via a simple SUM, use SUM. Iterators take more CPU power.
Wrong Table ReferencePassing a “Measures” table instead of a “Data” table as the first argument.Ensure the first part of the formula is the table containing the rows you want to loop through.
Related Table ErrorsTrying to multiply columns from two different tables without using RELATED.If your “Price” is in the Product table and “Quantity” is in Sales, use SUMX(Sales, Sales[Qty] * RELATED(Product[Price])).

5. Internal Library Links

Table of Contents
Scroll to Top