Smart Statistics · Power BI tutorial
Power BI date relationships: count orders on the right date
An order received on Friday and dispatched on Monday belongs to two operational days. A report can count it correctly and still put it in the wrong month.
Build two measures against one calendar, then prove what each date selection means.
23 November 2026 · Editable Import model in Power BI Desktop · Basic DAX and relationship knowledge
Illustrative example · all dashboard figures
November activity review
Test status: month-end crossover included
Make the question explicit
A UK wholesaler wants to compare incoming demand with dispatch activity. “Orders this month” could mean orders placed this month or orders sent this month, including older work.
This tutorial uses one row per order and one final dispatch date. It counts orders, not parcels, lines, value or partial shipments. If orders leave in several shipments, use a shipment-level fact table for dispatch activity and agree the completion definition separately.
Load a sample that crosses month-end
In a new Power BI Desktop file, choose Home → Enter data. Create this table and name it Orders. Leave the final DispatchDate cell empty. Use Transform data to set OrderID to Text and both date columns to Date, using English (United Kingdom) locale if needed. Close & Apply.
| OrderID | OrderDate | DispatchDate |
|---|---|---|
| A | 28/10/2026 | 30/10/2026 |
| B | 31/10/2026 | 02/11/2026 |
| C | 01/11/2026 | 03/11/2026 |
| D | 02/11/2026 | 04/11/2026 |
| E | 03/11/2026 |
Confirm five unique, non-blank IDs and no blank order dates. Keep the missing dispatch date as null, not “Pending” or a placeholder date. In production, validate duplicates and dates before loading. Convert timestamps to the agreed business time zone before extracting date-only keys.
Create one calendar and two date paths
Choose Modelling → New table and enter this complete definition. Its range comes from both date columns and includes full calendar years. The input must contain at least one valid date.
Calendar =
VAR EventDates =
FILTER(
UNION(
SELECTCOLUMNS(Orders, "EventDate", Orders[OrderDate]),
SELECTCOLUMNS(Orders, "EventDate", Orders[DispatchDate])
),
NOT ISBLANK([EventDate])
)
VAR FirstDate = MINX(EventDates, [EventDate])
VAR LastDate = MAXX(EventDates, [EventDate])
RETURN
ADDCOLUMNS(
CALENDAR(
DATE(YEAR(FirstDate), 1, 1),
DATE(YEAR(LastDate), 12, 31)
),
"YearMonth", FORMAT([Date], "yyyy-MM")
)
Set Calendar[Date] to Date. Select Calendar and Mark as date table, choosing Date. In Model view, create these relationships with single-direction filtering from Calendar to Orders:
- Active: Calendar[Date] (one) → Orders[OrderDate] (many).
- Inactive: Calendar[Date] (one) → Orders[DispatchDate] (many). Clear “Make this relationship active”.
The solid line should connect to OrderDate; the dashed line to DispatchDate. Use explicit Calendar fields in visuals, not automatic date hierarchies from Orders. The calculated calendar updates on model refresh, not when a reader changes a slicer.
Give each measure its own date meaning
Select Orders and create each definition as a separate New measure. Format both as whole numbers.
Orders Received =
COALESCE(COUNTROWS(Orders), 0)
Orders Dispatched =
COALESCE(
CALCULATE(
COUNTROWS(Orders),
USERELATIONSHIP(Orders[DispatchDate], 'Calendar'[Date]),
KEEPFILTERS(NOT ISBLANK(Orders[DispatchDate]))
),
0
)
Orders Received follows the active order-date relationship. Within Orders Dispatched, USERELATIONSHIP selects the existing dispatch-date relationship in place of that active path. The non-blank condition also excludes open orders when no calendar filter is applied. CALCULATE evaluates the count in the modified filter context.
This switches the calendar path for that calculation. It does not remove unrelated filters or a direct filter on Orders[OrderDate]. Avoid mixing raw fact-date slicers into this page.
Prove the result before styling the chart
Build a reconciliation matrix
Add Calendar[YearMonth] to Rows and both measures to Values. Filter YearMonth to 2026-10 and 2026-11. Add a Calendar[Date] Between slicer for daily tests. Keep measure names visible.
Then add a clustered column chart with YearMonth on the X-axis and both measures on the Y-axis. Title it “Orders received and dispatched by event month”.
Expected results
| Period | Received | Dispatched |
|---|---|---|
| October | 2 | 1 |
| November | 3 | 3 |
| Both months | 5 | 4 |
For 2 November alone: received = 1 (D), dispatched = 1 (B). Equal counts represent different orders.
Clear all calendar filters: expect 5 and 4. Temporarily change B's dispatch date to 31 October and refresh: October dispatches become 2 and November dispatches become 2; receipts stay unchanged. Restore the sample afterwards.
If monthly measures match unexpectedly, inspect relationships and visual fields. If totals exceed five orders, inspect the input grain. If a known dispatch disappears, check its date type, time component and calendar coverage before editing DAX.
Best practice: know this design's limits
Independent date questions need independent date roles
This design compares event counts under the same calendar selection. To ask “orders received in October and dispatched in November”, use separate Order Date and Dispatch Date dimensions with active relationships. A shared calendar cannot express two independent selections.
Review security and completion rules separately
Microsoft recommends active relationships where possible, especially with row-level security. Inactive relationships do not propagate RLS filters even when a measure uses USERELATIONSHIP, and some RLS configurations prohibit its use. Test security roles in the actual model; this tutorial is not an access-control design.
Do not label the difference between monthly measures “month-end backlog”. Backlog needs an as-of rule, opening work and treatment of cancellations. A dispatch date also does not prove on-time delivery.
Put the definition into everyday use
The operations owner defines final dispatch, cancellation treatment and responsibility for missing dates. The model owner maintains relationships, calendar and measures. The report owner keeps titles and tooltips explicit about each event date.
Ask a colleague to explain order B's October receipt and November dispatch without help. Pilot one reporting page, reconcile it to the order log and record sign-off. Track date-related corrections, reconciliation time and unresolved missing dispatch dates. Judge benefit using measured rework; this sample establishes no financial savings.
Check readiness for a pilot
Selections are not stored or transmitted. A score is not approval.
Frequently asked questions
Does USERELATIONSHIP create a relationship?
No. The relationship must already exist in the model. The function selects it for the calculation.
Is dispatched divided by received a fulfilment rate?
Not in this report. The measures select different populations by different dates. A fulfilment rate needs an agreed order cohort and completion rule.
When should I use separate date tables?
Use separate role-specific date tables when readers need independent order-date and dispatch-date filters at the same time. Review security requirements before choosing the design.
Make every date answer the intended question
Smart Statistics can help you build Power BI models that separate demand, activity and completion, with clear measures and practical reconciliation tests.