Conditional totals with SUMX and FILTER
Add up only the order lines that pass a row-by-row test, like sales from orders of three or more units.
You will learn to
- Keep only the rows that pass a test with FILTER
- Iterate a filtered table with SUMX
- Write a row condition with a comparison operator
How it works
Sometimes you only want to add up **some** of the rows: the big orders, the discounted lines, the sales above a threshold. The test belongs to each row, so you need a table that contains only the rows that pass.
`FILTER(Sales, condition)` walks through the visible Sales rows and keeps the ones where the condition is true. Inside the condition you are on one row at a time, so `Sales[Quantity]` means *this line’s* quantity.
`FILTER` returns a table, which is exactly what an iterator wants as its first argument. `SUMX(FILTER(Sales, …), Sales[Amount])` adds up the amount of each surviving row.
Practice it hands-on with a real data model and a live report that updates as you type.
Big Ticket Sales = SUMX(FILTER(Sales, Sales[Amount] >= 1000), Sales[Amount])