Sales by ship date with USERELATIONSHIP

Switch on an inactive relationship for one measure, so the same date axis can show sales by order date or by ship date.

You will learn to

  • Explain active and inactive relationships
  • Turn on an inactive relationship with USERELATIONSHIP
  • Compare two date roles on one axis

How it works

Sales has **two** dates: `Sales[DateKey]` (when the order was placed) and `Sales[ShipDateKey]` (when it left the warehouse). Both are related to `'Date'[DateKey]`, but only one relationship between two tables can be **active** at a time.

The order-date relationship is active, so every measure follows it by default: a month in the visual means “orders placed that month”. The ship-date relationship is **inactive** — it exists in the model but nothing uses it until you ask.

`USERELATIONSHIP(Sales[ShipDateKey], 'Date'[DateKey])` asks. It only works as a filter inside `CALCULATE`, and while that CALCULATE runs, the ship-date relationship takes over and the order-date one steps aside.

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

Lines by Ship Date = CALCULATE([Order Lines], USERELATIONSHIP(Sales[ShipDateKey], 'Date'[DateKey]))