Power BI (DAX) Guide · Prompt: “Multiply Quantity by UnitPrice row by row in OrderLines table and sum total using DAX SUMX”
Multiply Columns Row-by-Row with Power BI DAX SUMX
Verified by LiveFormulaLab Engineering Team • Updated November 2026
Multiply Quantity by UnitPrice per row and total the result dynamically in Power BI without a calculated column using DAX SUMX.
Verified Power BI (DAX) Syntax
SUMX(OrderLines, OrderLines[Quantity] * OrderLines[UnitPrice])How This Formula Works (Step-by-Step)
Standard SUM only accepts a single column and cannot multiply two columns together before summing. SUMX iterates row-by-row in memory.
Step 1: OrderLines tells DAX which table to scan one row at a time.
Step 2: OrderLines[Quantity] * OrderLines[UnitPrice] evaluates the line total for each row and adds all row totals together cleanly.
Formula Syntax & Arguments Breakdown
Iterates line-by-line over the OrderLines table via SUMX to evaluate Quantity * UnitPrice in row context before aggregating all line totals into one measure.
| Argument / Clause | Requirement | Data Type | Role & Behavior |
|---|---|---|---|
table (OrderLines) | Required | Table Expression | Fact table (or filtered table expression) scanned row-by-row during measure evaluation. |
expression (OrderLines[Quantity] * OrderLines[UnitPrice]) | Required | Row-Context Formula | Arithmetic or conditional calculation evaluated for each row prior to summing. |
3 Real-World Use Cases
- Calculating total order revenue without bloating the Power BI model with a calculated column.
- Computing weighted discounts: SUMX(Sales, Sales[Amount] * (1 - Sales[DiscountPct])).
- Evaluating COGS and gross profit dynamically inside matrix subtotals.
Cross-Platform Equivalents
- Excel
=SUMPRODUCT(B2:B5, C2:C5)- SQL
SELECT SUM(quantity * unit_price) AS total_sales FROM order_lines;- Python Pandas
(df['Quantity'] * df['UnitPrice']).sum()- Power BI (DAX)
SUMX(OrderLines, OrderLines[Quantity] * OrderLines[UnitPrice])
Common Mistakes & Pro Tips
Pitfalls & How to Fix Them
Mistake: Replacing SUMX with SUM(OrderLines[Quantity]) * SUM(OrderLines[UnitPrice]) multiplies column totals instead of line items, wildly inflating numbers.
Fix: Whenever multiplying or subtracting two columns per row, always use an X-iterator like SUMX or AVERAGEX.
Mistake: Creating a physical calculated column for LineTotal wastes permanent model memory when a dynamic SUMX measure works at query time.
Fix: Prefer SUMX measures over calculated columns unless you specifically need to slice or group visuals by LineTotal buckets.
Mistake: Calling another measure inside SUMX without realizing it triggers context transition can hurt performance on huge tables.
Fix: Reference raw columns (Table[Col]) inside high-volume SUMX iterators whenever possible.
Engineering Pro Tips
- Use SUMX(FILTER(OrderLines, OrderLines[Status] = "Shipped"), ...) or wrap SUMX inside CALCULATE to scope line totals cleanly.
- Combine SUMX with RELATED() when Quantity lives on Sales and UnitPrice lives on a parent Products dimension table.
- The exact same pattern works with AVERAGEX, MINX, and MAXX for per-order ticket metrics.
Frequently Asked Questions
- Why is SUMX better than adding a calculated column?
- Calculated columns consume permanent RAM in the VertiPaq model. A SUMX measure evaluates dynamically at query time using zero extra storage.
- What happens if I multiply SUM(Qty) * SUM(Price) instead?
- Multiplying two separate SUMs aggregates first and multiplies totals—giving massively inflated numbers instead of line-item sums.
- Can I filter the table inside SUMX?
- Yes, wrap the first argument in FILTER(OrderLines, OrderLines[Status] = "Shipped") or wrap SUMX inside CALCULATE().
Related Formulas & Guides
- Safe Division & Profit Margin with DAX DIVIDE — Prevent Infinity and NaN visual errors in Power BI ratios and profit margins using the DAX DIVIDE function with a custom fallback.
- Look Up Dimension Values in Power BI Using DAX RELATED — Pull columns from a parent dimension table into a child fact table in Power BI using DAX RELATED instead of fragile VLOOKUP formulas.
- Cumulative Year-to-Date Running Total with DAX DATESYTD — Build a cumulative Year-to-Date (YTD) sales measure in Power BI using CALCULATE and DATESYTD with optional fiscal year-end support.
- Count Unique Customers Accurately with DAX DISTINCTCOUNT — Count unique active customers, orders, or SKUs accurately across any Power BI filter slice or date range using DAX DISTINCTCOUNT.