Last purchase date per customer with MAXX and RELATED

Find each customer’s most recent purchase date, and see why MAX on the date table gives the wrong answer.

You will learn to

  • Explain why a Customer filter does not filter the Date table
  • Find the latest date among the visible sales with MAXX and RELATED
  • Build a measure that returns a date

How it works

“When did each customer last buy?” is one of the most useful questions in sales reporting, and it has a classic trap.

The tempting answer is the latest value of `'Date'[Date]`. But filters flow from lookup tables **down** to Sales, never back up. A Customer row filters Sales to that customer’s orders, and it stops there: the Date table still shows all 731 days, so its latest date is 31 December 2025 for everyone.

The fix is to start from the rows that **are** filtered. An iterator such as `MAXX(Sales, …)` walks over the customer’s visible sales, and `RELATED('Date'[Date])` looks up each sale’s date along the relationship. The largest of those dates is the last purchase. (The highest `Sales[DateKey]` is the right day too, but it is a number like 20251228, not a date.)

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

Highest List Price Sold = MAXX(Sales, RELATED(Product[Price]))