Count matching rows with COUNTROWS and FILTER
Count only the order lines that meet a condition, such as every line that was sold at a discount.
You will learn to
- Count the rows of a filtered table
- Choose the right column for a row condition
How it works
`COUNTROWS(Sales)` counts every visible order line. To count only the lines that meet a condition, hand it a smaller table instead.
`FILTER(Sales, condition)` produces that table. Wrap it in `COUNTROWS` and you get “how many lines passed the test” in whatever the visual is showing.
Each line in this model stores its discount rate in `Sales[Discount]`: 0 for full price, or 0.05 or 0.1 when a discount was given.
Practice it hands-on with a real data model and a live report that updates as you type.
Single-Unit Lines = COUNTROWS(FILTER(Sales, Sales[Quantity] = 1))