Sub topic 7
Year-to-Date and Other Time Intelligence by Ship Date
This chapter assumes you can write basic DAX measures and use CALCULATE. It also assumes your model already has a Sales fact table with OrderDate and ShipDate columns. OrderDate has the active relationship to 'Date'[Date], and ShipDate has an inactive one. The previous chapters built the Sales Amount by Ship Date measure. Here you combine USERELATIONSHIP with time intelligence functions such as DATESYTD, so that running totals, prior-year comparisons, and rolling windows follow ship date instead of order date.
What changes when the date role changes
Time intelligence functions such as DATESYTD, SAMEPERIODLASTYEAR, and DATEADD do not know anything about order dates or ship dates. They read the current filter context on the Date table and return a new set of dates from that table. For example, DATESYTD returns every date from January 1 up to the last date in the current context.
Those dates reach the fact table through whichever relationship is active when the calculation runs. By default that is Sales[OrderDate]. So the same DATESYTD call can mean "orders placed so far this year" or "orders shipped so far this year". The date function stays the same. Only the relationship it travels through changes.
CALCULATE accepts both pieces as arguments: the relationship switch and the date filter.
The year-to-date measure
The measure from the plan combines both arguments in one CALCULATE:
Shipped Sales YTD =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ),
DATESYTD ( 'Date'[Date] )
)CALCULATE evaluates this in three steps:
- It reads the current filter context from the visual, for example Month = February 2026 on the
Datetable. DATESYTD ( 'Date'[Date] )is evaluated in that context. It returns all dates from January 1, 2026 through February 28, 2026, and these replace the existing filter on'Date'[Date].USERELATIONSHIPswitches theSales[ShipDate]relationship on and theSales[OrderDate]relationship off for the duration of this calculation. The date filter then flows intoSalesthroughShipDate, andSUMruns over the surviving rows.
The order of the arguments inside CALCULATE does not matter. USERELATIONSHIP is a modifier, not a filter, so it takes effect for the whole calculation regardless of its position.
A worked example with numbers
Suppose Sales holds these five rows. The Date table covers December 1, 2025 through December 31, 2026.
| OrderID | OrderDate | ShipDate | SalesAmount |
|---|---|---|---|
| 1 | 2025-12-28 | 2026-01-03 | 100 |
| 2 | 2026-01-10 | 2026-01-12 | 200 |
| 3 | 2026-02-05 | 2026-02-20 | 300 |
| 4 | 2026-02-25 | 2026-03-02 | 400 |
| 5 | 2026-03-15 | (blank) | 500 |
Grouped by month, the three measures return:
| Month | Sales Amount (order date) | Sales Amount by Ship Date | Shipped Sales YTD |
|---|---|---|---|
| Dec 2025 | 100 | blank | blank |
| Jan 2026 | 200 | 300 | 300 |
| Feb 2026 | 700 | 300 | 600 |
| Mar 2026 | 500 | 400 | 1000 |
Three details are worth noticing:
- Order 1 was placed in December but ships in January, so it moves from the December row to the January row.
- The YTD column for Jan through Mar accumulates the ship-date column: 300, then 300 + 300 = 600, then 600 + 400 = 1000.
- Order 5 has no ship date. A blank value matches no row in the
Datetable, so the order never appears in any ship-date measure. For calendar year 2026, the order-date total is 1400 and the ship-date total is 1000. The 400 gap comes from order 1 (100 shipped in 2026 but ordered in 2025, which adds to the ship-date side) and order 5 (500 never shipped), so net: 1400 - 500 + 100 = 1000.
You can verify this in DAX Studio or the DAX query view. The query below assumes your Date table has Year, Month Number, and Month columns, and defines the measures locally.
DEFINE
MEASURE Sales[Sales Amount] = SUM ( Sales[SalesAmount] )
MEASURE Sales[Sales Amount by Ship Date] =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)
MEASURE Sales[Shipped Sales YTD] =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ),
DATESYTD ( 'Date'[Date] )
)
EVALUATE
SUMMARIZECOLUMNS (
'Date'[Year],
'Date'[Month Number],
'Date'[Month],
"Order Date Sales", [Sales Amount],
"Ship Date Sales", [Sales Amount by Ship Date],
"Shipped YTD", [Shipped Sales YTD]
)
ORDER BY 'Date'[Year], 'Date'[Month Number]Layering measures instead of repeating USERELATIONSHIP
Repeating USERELATIONSHIP in every measure is easy to get wrong. A cleaner pattern is to create one base measure that carries the ship-date role and build the time intelligence on top of it.
Shipped Sales =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)
Shipped Sales YTD (layered) =
CALCULATE ( [Shipped Sales], DATESYTD ( 'Date'[Date] ) )This returns the same numbers as the combined form. The outer CALCULATE replaces the filter on 'Date'[Date] with the year-to-date set. The inner CALCULATE, inside [Shipped Sales], then activates the ship-date relationship. That filter on the Date table is still in place when the inner calculation runs, and it now travels through ShipDate.
The layered form gives you one place to change if the column or the Date table is renamed. It also reads well: a measure called Shipped Sales YTD (layered) is built from Shipped Sales and nothing else.
Other time intelligence functions
Every function that returns dates from the Date table works the same way. Add USERELATIONSHIP and the new date set filters by ship date.
Shipped Sales PY =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ),
SAMEPERIODLASTYEAR ( 'Date'[Date] )
)
Shipped Sales YoY % =
DIVIDE ( [Shipped Sales] - [Shipped Sales PY], [Shipped Sales PY] )
Shipped Sales Rolling 3M =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ),
DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )
)
Shipped Sales Fiscal YTD =
CALCULATE (
[Sales Amount],
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ),
DATESYTD ( 'Date'[Date], "6/30" )
)The last measure passes a year-end date to DATESYTD, so the year-to-date window starts July 1. Use the form that matches your fiscal calendar.
If you prefer TOTALYTD, put it inside an outer CALCULATE that carries the relationship:
Shipped Sales TOTALYTD =
CALCULATE (
TOTALYTD ( [Sales Amount], 'Date'[Date] ),
USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] )
)The relationship set by the outer CALCULATE stays in effect for the nested CALCULATE that TOTALYTD performs internally. Many people still prefer the explicit CALCULATE plus DATESYTD form, because every modifier is visible on the page.
Pitfalls specific to alternate-date time intelligence
Forgetting USERELATIONSHIP in one measure
If Shipped Sales YoY % calls [Shipped Sales] and [Shipped Sales PY], both carry the ship-date role and the result is consistent. If you accidentally write [Sales Amount] in place of [Shipped Sales PY], the YoY measure divides ship-date sales by order-date sales. The result looks plausible and is wrong. Naming measures with a "Shipped" prefix makes this mistake easier to spot.
Ship dates outside the Date table
If a ship date falls after the last date in the Date table, that row has no match. The row is not lost from the model, but it can appear under a blank group in visuals that use Date columns and disappear from every dated cell. Extend the Date table so it covers future ship dates too.
Blank ship dates for unshipped orders
Unshipped orders, such as order 5 in the example, never appear in ship-date measures. This is usually correct, because they have not shipped yet. Just do not expect the grand totals of an order-date measure and a ship-date measure to match. If you need to reconcile them, add a measure for unshipped sales:
Unshipped Sales =
CALCULATE ( [Sales Amount], ISBLANK ( Sales[ShipDate] ) )Mixed roles in one visual
When one visual shows both Sales Amount and Shipped Sales by 'Date'[Month], each column filters the fact table differently. That is the goal, but label the columns clearly. A viewer who sees "Feb 2026: 700 and 300" without role names will assume the two numbers should agree.
Time intelligence at the total row
DATESYTD uses the last date in the current context. In a total row for a whole year, that is December 31, so the YTD value equals the full-year ship-date total. That is correct behavior, but it can look odd next to monthly rows that show smaller numbers.
Exercise
Using the sample data in this chapter, what does Shipped Sales YTD return for the March 2026 row, and what would the equivalent order-date YTD (DATESYTD without USERELATIONSHIP) return?
Show answer
Shipped Sales YTD for March 2026 is 1000: shipments of 300 in January, 300 in February, and 400 in March. Order-date YTD for March 2026 is 1400, which is 200 in January, 700 in February, and 500 in March. The 100 order placed in December 2025 falls in 2025 for order date, and order 5 counts on the order-date side even though it has not shipped.
Exercise
Write a measure called Shipped Sales Prior Month that returns ship-date sales for the previous month, built on the Shipped Sales base measure. Why is it better to build on the base measure than to repeat USERELATIONSHIP?
Show answer
Shipped Sales Prior Month = CALCULATE ( [Shipped Sales], DATEADD ( 'Date'[Date], -1, MONTH ) ). The base measure already contains USERELATIONSHIP ( Sales[ShipDate], 'Date'[Date] ), so the date shift reaches Sales through ShipDate without repeating it. Keeping the relationship in one measure means a column rename or role change is fixed in one place, and no derived measure can silently fall back to order date.