Related to a related table

I have a snowflake design because of the way the tables are formated coming from SAP. I am trying to create a calculation combining ship date and delivery date and they are in tables that have another table between them. How can I use both of them in the same measure? The ship date is in the RDR1 table and the Delivery date is in the All Database table. There is a relation between All Database and ORDR and another between ORDR and RDR1. How do you get it to pass/drill through?

It’s easier than you might expect. What measure are you hoping to create? What is the name of your date table?

I need to create a series of measures like the following:

Day’sLateActualDelLine = ‘ALL - Database’[Delivery Date] - RELATED(‘RDR1 SalesOrder Lines’[Ship Date])

My date table is just called Date.

ANSWER:

First, make sure you have relationships from your Date table to both ‘ALL - Database’[Delivery Date] and ‘RDR1 SalesOrder Lines’[Ship Date]. The date table will be a role-playing dimension.
Then, in the series of measures you have, just selectively activate the relationship you need using USERELATIONSHIP(), for example

<measure definition>
.
. 
.
   USERELATIONSHIP('Date'[Date], ‘ALL - Database’[Delivery Date])
.
.
.

or

<measure definition>

.
.
.
   USERELATIONSHIP('Date'[Date],‘RDR1 SalesOrder Lines’[Ship Date])
.
.
.

In your post above I dont see the date table or the relationships from it to those two columns so I would only be guessing about the right syntax, but you might have one that’s active and the other inactive. or they could both be inactive.

If that isnt enough to get you going post your .pbix file and we can walk through creating a few measures.

I tried what you suggested and for some reason, all the answers are zero. I have some that should be negative but I have yet to find a positive difference but they all report zero.

OTD.pbix (35.9 MB)

I might have led you down the wrong path initially :slight_smile: I looked at your pbix file. Does this does what you need:

Measure =
VAR ShipDate = CALCULATE(MIN('RDR1 -Sales Order - Rows'[ShipDate]))
VAR DeliveryDate = CALCULATE(MIN('ALL - Database'[Due Date]))
RETURN
DATEDIFF(ShipDate, DeliveryDate, DAY)

image

Not sure what kind of magic you did on the file to make it work that way. I removed the userelationships and got the same everything is zero result. I also can’t put ship date into the same visual with sales order and due date. I get no relationship exists.

I figured it out. I deleted the relationships to the date table and enabled the one between All Database and ORDR.