Count days with no sales with EXCEPT
Subtract one list from another with EXCEPT to find the calendar days that had no sales — set logic on virtual tables.
You will learn to
- Subtract one table from another with EXCEPT
- Compare a dimension list with the keys in a fact table
- Know which side of EXCEPT is which
How it works
DAX has three set operations for tables with the same number of columns:
- `UNION(a, b)`: every row of both (duplicates kept); - `INTERSECT(a, b)`: rows of a that are also in b; - `EXCEPT(a, b)`: rows of a that are **not** in b.
Order matters for EXCEPT: it keeps rows from the **first** table. `EXCEPT(list of all things, list of things that happened)` is “what didn’t happen”.
For dates, the first list is the calendar the cell can see, `VALUES('Date'[DateKey])`. The second is the dates that appear in Sales, `VALUES(Sales[DateKey])`. Both lists follow the current filters, including a category or region filter that only reaches Sales.
Practice it hands-on with a real data model and a live report that updates as you type.
Products Never Sold = COUNTROWS(EXCEPT(VALUES(Product[ProductKey]), VALUES(Sales[ProductKey])))