Count products with low stock at month end
Count how many products closed the month below a reorder threshold with COUNTROWS, FILTER and a closing balance, showing 0 instead of blank.
You will learn to
- Count items that meet a condition on a balance measure
- Iterate products, not inventory rows, so months aren’t counted twice
- Show 0 instead of blank on a trend line
How it works
"How many products are running low?" is a count of **products**, so iterate products: `FILTER(VALUES(Product[Product]), condition)` keeps the products that meet the condition, and `COUNTROWS` counts them. The condition uses the closing balance measure, evaluated for each product through context transition.
Don't filter the `Inventory` table instead. In a month row it happens to work (one row per product), but in a quarter or year row each product has several snapshot rows, and you'd count the same product up to twelve times.
When no product qualifies, `COUNTROWS` of an empty table is blank, and a trend line simply breaks there. Wrap the count in `COALESCE(…, 0)` to show a real zero.
Practice it hands-on with a real data model and a live report that updates as you type.
Overstocked Products = COALESCE(COUNTROWS(FILTER(VALUES(Product[Product]), [Closing Units] > 150)), 0)