Customers who bought this product and also that one (TREATAS)
Pick a second product on a slicer from a disconnected copy of the product list, and count the customers who bought both it and each product in the matrix.
You will learn to
- Explain why a second product slicer needs a disconnected table
- Apply a disconnected selection to the Product table with TREATAS
- Intersect the two groups of buyers
How it works
“Customers who bought **this** also bought **that**” needs two product selections at once: the matrix row (this) and a slicer (that). Both can’t come from the Product table, because a slicer on Product would filter the rows too. So the model has `'Compare Product'`, a disconnected copy of the product names that filters nothing on its own.
`TREATAS(VALUES('Compare Product'[Compare Product]), Product[Product])` takes the names selected on the slicer and applies them **as if** they were a filter on `Product[Product]`. Used in `CALCULATETABLE(VALUES(Sales[CustomerKey]), TREATAS(…))`, it gives the customers who bought the compared product. It replaces the row’s own product filter, because it filters the same column.
Then intersect that list with the customers of the current row, `VALUES(Sales[CustomerKey])`, and count.
Practice it hands-on with a real data model and a live report that updates as you type.
Sales of the Compared Product =
CALCULATE([Total Sales], TREATAS(VALUES('Compare Product'[Compare Product]), Product[Product]))