Active customers in the last 90 days with DATESINPERIOD

Count distinct customers who bought in the trailing 90 days, a rolling active-customer metric that can’t be built by adding up monthly counts.

You will learn to

  • Apply a rolling window to a distinct count
  • Explain why distinct counts are not additive
  • Count through the fact table, not the dimension

How it works

“How many customers are active?” usually means “bought something recently”, for example in the **last 90 days**. That’s a rolling window again, but around a **distinct count**.

Distinct counts don’t add up. A customer who bought in October, November and December is one active customer, not three. So you can’t sum monthly customer counts; you have to count distinct customers over the whole window in one go. Wrapping the existing `[Customers]` measure (a distinct count of `Sales[CustomerKey]`) in `CALCULATE` with a 90-day `DATESINPERIOD` does exactly that.

Count customers **through Sales**. The Date filter reaches the Sales table, not the Customer table, so counting `Customer[CustomerKey]` would always see all 40 customers.

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

Products Sold Last 30 Days = CALCULATE(DISTINCTCOUNT(Sales[ProductKey]), DATESINPERIOD('Date'[Date], MAX('Date'[Date]), -30, DAY))