Average products per customer: the fact table connects two dimensions

Measure how much of the range each customer buys by iterating Customer and counting distinct products in Sales.

You will learn to

  • Use the fact table to relate two dimensions that have no direct relationship
  • Turn each row of a dimension into a filter with CALCULATE
  • Average a per-customer count with AVERAGEX

How it works

There is no relationship between `Product` and `Customer`. They are connected only through `Sales`, which holds a product key and a customer key on every row. Questions that mix the two (“how many different products did each customer buy?”) are always answered through the fact table.

To get one number per customer, iterate the Customer table. Inside the iterator, `CALCULATE` turns the current customer row into a filter (**context transition**). That filter flows down to Sales, so a count over Sales now sees just that customer’s order lines — together with whatever the report is already filtering, like a year or a category.

`AVERAGEX` then averages those per-customer results. Customers who bought nothing in the period give a blank, and AVERAGEX skips blanks, so they don’t drag the average down.

Practice it hands-on with a real data model and a live report that updates as you type.

Avg Buyers per Product = AVERAGEX(Product, CALCULATE(DISTINCTCOUNT(Sales[CustomerKey])))