Find the busiest product with RELATEDTABLE
From each Product row, reach down to its sales with RELATEDTABLE and find the most order lines any one product has.
You will learn to
- Reach from a dimension row to its fact rows with RELATEDTABLE
- Explain why COUNTROWS(Sales) inside a Product iterator returns the same number on every row
- Find the largest per-product value with MAXX
How it works
**RELATED** looks up from a sale to its one product. **RELATEDTABLE** goes the other way: from a Product row, `RELATEDTABLE(Sales)` returns that product’s order lines — as a table, because there can be many.
It only makes sense inside a row context, such as an iterator over Product. For each product it behaves like CALCULATETABLE: the current product becomes a filter on Sales, and everything else the report filters (a region, a year) still applies.
That’s the difference from writing plain `Sales` inside the iterator. A row context on Product doesn’t filter anything by itself, so `COUNTROWS(Sales)` would count every visible order line on every product row.
Practice it hands-on with a real data model and a live report that updates as you type.
Avg Sales per Product = AVERAGEX(Product, SUMX(RELATEDTABLE(Sales), Sales[Amount]))