Count the days with sales with DISTINCTCOUNT

Count how many days in a month actually had a sale, with DISTINCTCOUNT on the date key in the Sales table.

You will learn to

  • Count days with activity using DISTINCTCOUNT on a fact table key
  • Tell calendar days apart from days with sales
  • Predict which tables a slicer filters

How it works

“How many days did we trade in July?” has two possible answers, and they come from two different tables.

- The **Date** table has one row for every calendar day. Counting its rows gives the number of days in the period: 31 for July, whether you sold anything or not. - The **Sales** table only has rows for days when something was sold. Each sale carries its day in a key column, so counting the **different** day keys in Sales gives the number of days with at least one sale.

A busy day with ten sales still counts once, which is why you want a distinct count rather than a row count. And because the count comes from Sales, it follows every filter that reaches Sales: pick North, and you get the days North customers bought something.

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

Products Sold = DISTINCTCOUNT(Sales[ProductKey])