What is SUMX in Power BI?

Cody Schneider8 min read

Trying to understand how SUMX works in Power BI can feel like a rite of passage for anyone learning DAX. If you've ever tried to calculate total revenue and realized that SUM([Quantity]) * SUM([Price]) gives you a ridiculously huge, incorrect number, you've stumbled upon the exact problem SUMX was designed to solve. This article will break down what SUMX is, why it's different from the familiar SUM function, and show you practical examples to turn this point of confusion into a powerful tool in your analytics arsenal.

First, Let's Talk About SUM vs. SUMX

To really appreciate what SUMX does, you have to first be clear on what a regular SUM function does. It’s simple, familiar, and works just like it does in Excel.

The SUM() function is a standard aggregator. You give it a single column of numbers, and it adds them all up. Simple.

SUM(Sales[Sale Amount])

This formula totals all the values in the 'Sale Amount' column of your 'Sales' table. Easy.

The SUMX() function, on the other hand, is what’s known as an iterator function. That one letter - X - changes everything. Iterator functions don't just act on an entire column at once. Instead, they go through a specified table row by row, perform a calculation that you define for each row, and then aggregate the results of those individual calculations.

Here’s a simple analogy: imagine you’re calculating the total for a grocery receipt.

  • SUM is like looking at a receipt that already has a "Line Total" column for each item. You would just add up the values in that pre-calculated column.
  • SUMX is like getting a receipt with only 'Item Price' and 'Quantity' columns. You'd take out your calculator, go through the receipt line by line, multiplying the 'Item Price' by 'Quantity' for the bananas, then the milk, then the bread. After calculating each line total, you would add them all up to get the grand total.

That row-by-row evaluation is the core concept of SUMX and all other "X" functions in DAX.

How SUMX Works: The Syntax Breakdown

The syntax for SUMX looks simple, but it’s packed with power. Understanding its two main components is key to using it effectively.

SUMX(<table>, <expression>)

Part 1: <table>

This is the first argument, and it tells SUMX which table to loop through. You have to specify a physical or virtual table. This could be a direct reference to an existing table in your data model, like 'Sales' or 'Inventory'. More often than not, you'll use a table function here, like FILTER() or ALL(), to create a virtual table on the fly. This is where a lot of the advanced logic happens.

Part 2: <expression>

This is the calculation that SUMX will perform for every single row of the table you specified in the first argument. This expression has access to the values of all a particular row's columns as it iterates through them. This ability to work with multiple values from the same row is precisely what SUM() can't do. For example, your expression might be multiplying Sales[Quantity] * Sales[Unit Price].

So, the two parts work together: SUMX takes the <table>, iterates over it one row at a time while evaluating the <expression>, for each row, temporarily storing the result, and finally, summing up all of those temporary results.

Practical Example 1: Calculating Total Revenue

Let's make this tangible with the most common use case: calculating total sales revenue when you don't have a pre-calculated 'Total Sale' column. Imagine you have a 'Sales' table that looks like this:

Your Sales Data:

  • Product: "Laptop" | Quantity: 2 | Unit Price: 1200
  • Product: "Mouse" | Quantity: 5 | Unit Price: 25
  • Product: "Keyboard" | Quantity: 3 | Unit Price: 75

If you were to write a DAX measure to calculate total revenue, your first instinct might be:

Wrong Total Revenue = SUM(Sales[Quantity]) * SUM(Sales[Unit Price])

What does this actually calculate?

It first calculates SUM(Sales[Quantity]) which is 2 + 5 + 3 = 10.

Then, it calculates SUM(Sales[Unit Price]) which is 1200 + 25 + 75 = 1300.

Finally, it multiplies them: 10 * 1300 = 13,000. This number is meaningless.

Now let's do it the right way with a SUMX() measure:

Total Revenue = SUMX(Sales, Sales[Quantity] * Sales[Unit Price])

Here's what happens behind the scenes:

  1. SUMX starts iterating through the Sales table.
  2. Row 1 (Laptop): It evaluates the expression Sales[Quantity] * Sales[Unit Price], which is 2 * 1200 = 2400. It holds this number in memory.
  3. Row 2 (Mouse): It evaluates 5 * 25 = 125. Holds it in memory.
  4. Row 3 (Keyboard): It evaluates 3 * 75 = 225. Holds it in memory.
  5. Now that it has processed all the rows in the table, SUMX adds up the results it calculated: 2400 + 125 + 225.
  6. It returns the final, correct result: 2750.

That row-level calculation is the magic of SUMX, enabling you to create accurate aggregate measures from columns containing underlying components of the final number you are looking after.

Leveling Up: Combining SUMX with FILTER

SUMX really levels up when you combine it with another DAX table function. Now imagine you've been asked for the total revenue for just laptops. This is where the FILTER() function comes in. Remember the <table> argument in SUMX? Instead of giving it the entire Sales table, we can give it a filtered version of that table—a virtual table that only exists temporarily as DAX executes the expression:

Laptop Revenue = 
SUMX(
    FILTER(
        Sales, 
        Sales[Product] = "Laptop"
    ),
    Sales[Quantity] * Sales[Unit Price]
)

Here’s how DAX reads this formula:

  1. First, it evaluates the inner FILTER() function. This creates a new temporary table in memory, which contains only the rows from the Sales table where the Product is “Laptop”. Using the table from before, this means we'll only work with the one row pertaining to laptops—but if your 'Sales' table has hundreds of other SKUs and multiple rows for laptop sales transactions, this would grab all laptop-related entries.
  2. Next, SUMX gets to work. But instead of iterating over the entire Sales table, it only iterates over the smaller, filtered table.
  3. It then calculates the expression quantity * unitPrice across multiple lines of your filtered "laptops only" table and performs the final addition to accurately present the total for the "Laptops" category across multiple rows of sales transactions.

When to Choose SUMX: Common Use Cases

You should reach for SUMX instead of SUM anytime you need to perform calculations at a row level before you aggregate. Here are a few common scenarios where SUMX is your best friend:

  • When calculating totals from component columns: The Revenue = Quantity * Price example is the classic case. Other examples might be Total Cost = Units Sold * Unit Cost or Shipping Profit = Revenue Earned - Actual Shipping Cost.
  • Conditional Aggregations: Any time you need to sum values based on criteria from another column in the same table, (e.g., sum of all discounted sales for orders larger than $300). You’ll use SUMX along with FILTER or other conditional logic.
  • Applying complex business logic: Imagine you have a tiered pricing. Maybe orders over 100 units get a 10% discount. That kind of row-level logical check (IF) must happen before summing, making SUMX essential.
  • Calculating weighted averages: This is a powerful use case. You can calculate weighted metrics, for example (Weighted Average Price = SUMX(Sales, Sales[Unit Price] * Sales[Quantity]) / SUM(Sales[Quantity])). Then divide that by the Total_Quantity, and this will accurately calculate your weighted average by respecting units sold per product, per row, at a given transaction price.

Common Traps and Quick Tips

  • Don't overuse SUMX: Calculated Columns Might Be Better: Row-by-row iteration can be slow on tables with very large datasets—like millions of rows. If your formula is a simple row-level calculation that doesn't change based on user filters, then it is probably best served by being created via a calculated column that gets computed once at the time where an analyst refreshes the given dataset rather than on the fly. A measure, on the other hand, is not pre-calculated. It recalculates its answer every time it is used on the fly, so if you have multiple visuals in a Power BI dashboard, it will do it every single time a report visual is used.
  • SUMX-ing a single column: "a rookie's mistake." SUMX(Sales, Sales[Sale Amount]) gives the right answer every time it's executed. It is functionally the exact same as SUM(Sales[Sale Amount]), but does it by taking an unnecessary trip, taking the longer route and becoming the slightly less-efficient function call.

Final Thoughts

Hopefully, SUMX is not as intimidating any longer. The 'X' stands for an iterator. It's your go-to for row-by-row calculations before aggregating, which moves your data in ways a single sum-of-single column can't possibly achieve. SUMX is where true analytical power with DAX is really unlocked. You specify both your engine—the row-level operation (Expression)—and what road trip it goes over (Tables), giving the ultimate flexible analytic option.

Mastering DAX functions like SUMX and FILTER takes hours of practice. We started Graphed because we believe valuable insights shouldn't be locked behind a steep learning curve or complex syntax. Instead of writing formulas to calculate your total revenue, you can just ask in plain language: "What was our total revenue last month, broken down by product?" and Graphed builds a live, interactive dashboard for you instantly. We streamline report generation, allowing you and your business team to get clear, immediate answers to all their BI questions from their company’s own data.

Related Articles

How to Connect Facebook to Google Data Studio: The Complete Guide for 2026

Connecting Facebook Ads to Google Data Studio (now called Looker Studio) has become essential for digital marketers who want to create comprehensive, visually appealing reports that go beyond the basic analytics provided by Facebook's native Ads Manager. If you're struggling with fragmented reporting across multiple platforms or spending too much time manually exporting data, this guide will show you exactly how to streamline your Facebook advertising analytics.

Appsflyer vs Mixpanel​: Complete 2026 Comparison Guide

The difference between AppsFlyer and Mixpanel isn't just about features—it's about understanding two fundamentally different approaches to data that can make or break your growth strategy. One tracks how users find you, the other reveals what they do once they arrive. Most companies need insights from both worlds, but knowing where to start can save you months of implementation headaches and thousands in wasted budget.