Ravindra BagaleCourses & study guides मराठी Track your progress

13. DAX: Data Analysis Expressions

13.12 USERELATIONSHIP in Power BI DAX with Example

USERELATIONSHIP in Power BI with example — in 30 seconds

What: USERELATIONSHIP turns on an inactive (dotted) relationship for one measure.

Why: An order placed on 31 March at 11:55 pm may be delivered on 1 April. Finance books it by delivered date.

Tiny example: By order date, 31-Mar = ₹800. By delivered date, 31-Mar = ₹300 and 1-Apr = ₹500.

First look at the data (before → after):

USERELATIONSHIP in Power BI with example: before and after tables, fictional Blinkit Maharashtra data

Same before / after tables as text

Before — Orders with two dates

Order ID Order Date Delivered Date Amount (₹)
BLK-401 31-03-2025 31-03-2025 300
BLK-402 31-03-2025 01-04-2025 500

About this data: This table uses columns: Order ID, Order Date, Delivered Date, Amount (₹). This table uses columns: Date, Total Sales (Order Date, active), Sales by Delivered Date. Values shown are the lesson examples already on this page (not a new dataset).

Formula / click path

Sales by Delivered Date = CALCULATE([Total Sales],
    USERELATIONSHIP(Orders[Delivered Date], 'Date'[Date]))

After — Matrix by Date

Date Total Sales (Order Date, active) Sales by Delivered Date
31-03-2025 ₹800 ₹300
01-04-2025 (blank) ₹500

Do it step by step:

  1. In Model view, check Date[Date] → Orders[Order Date] is solid (active).
  2. Check Date[Date] → Orders[Delivered Date] is dotted (inactive).
  3. New measure: Sales by Delivered Date (formula above).
  4. Matrix: Rows = Date, Values = both measures. Check the table above.
  5. Notice: 1-Apr is the first day of FY 2025-26. ₹500 moves to the new financial year.

Activates an inactive relationship for one calculation. It only works inside CALCULATE (or CALCULATETABLE).

Sales by Delivered Date =
CALCULATE([Total Sales], USERELATIONSHIP(Orders[Delivered Date], 'Date'[Date]))

Orders Delivered (by delivery date) =
CALCULATE([Delivered Orders], USERELATIONSHIP(Orders[Delivered Date], 'Date'[Date]))

Put Date on the axis and show [Delivered Orders] and [Orders Delivered (by delivery date)] side by side: the small differences come from orders placed just before midnight and delivered the next day.

Ravindra Bagale's Tip

Friends, many students create a second active relationship, Power BI makes it inactive, and then they think the relationship "doesn't work". That is by design: only one active path is allowed. Use USERELATIONSHIP inside CALCULATE for measures such as Sales by Delivered Date. Try it once more, then move on.

Loading DAX practice tasks...

  1. Sales by order date (Easy): Shown per FY. Measure: Order Sales that simply reuses the Total Sales measure.
  2. Sales by delivery date (Easy): Shown per FY. Measure: Delivered Sales = [Total Sales] using the DeliveredDate relationship.
  3. Delivered units (Easy): Shown per FY. Measure: Delivered Qty = [Total Qty] using the delivery date.
  4. Delivered sales this FY (Medium): Slicer: FY 2025-26. Measure: Delivered Sales = [Total Sales] by delivery date.
  5. Delivered orders per quarter (Medium): Slicer: FY 2024-25. Shown per FYQuarter. Measure: Delivered Orders = [Total Orders] by delivery date.
  6. Average delivery minutes by delivery FY (Medium): Shown per FY. Measure: Delivered Avg Mins = average of DeliveryMins using the delivery date.
  7. Late deliveries (Medium): Measure: Next Day Deliveries = number of Orders rows where DeliveredDate is after OrderDate.
  8. Pune deliveries by FY (Hard): Shown per FY. Measure: Pune Delivered = [Total Sales] for City "Pune" using the delivery date.
  9. Delivered sales per city this FY (Hard): Slicer: FY 2025-26. Shown per Store City. Measure: Delivered Sales = [Total Sales] by delivery date.
  10. Delivered units in March (Hard): Slicers: FY 2024-25 and Month Mar. Measure: Delivered Qty = [Total Qty] by delivery date.

Ravi Sir's Cards for this lesson

मराठी cards