Average spend per customer per month with SUMMARIZE and AVERAGEX

Average over customer-month combinations with SUMMARIZE and AVERAGEX to see what a typical customer spends in a month they shop.

You will learn to

  • Iterate a SUMMARIZE table with AVERAGEX
  • Explain how lineage columns drive context transition
  • Pick the right grain for an average

How it works

An average is only as good as the thing you average **over**. Sales per customer, per month and per customer-month are three different numbers.

SUMMARIZE can build that grain for you: `SUMMARIZE(Sales, Customer[Customer], 'Date'[Month Year])` is one row per customer per month in which that customer actually bought something.

The columns of that table keep their **lineage**: they still belong to Customer and Date. So when an iterator such as `AVERAGEX` evaluates a measure on each row, context transition filters both the customer and the month, and the measure returns that customer’s sales in that month. Months a customer skipped are not in the table, 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 Region-Month Units = AVERAGEX(SUMMARIZE(Sales, Customer[Region], 'Date'[Month Year]), [Total Quantity])