Forum Discussion

Danielnir's avatar
Danielnir
Helper II
3 years ago

Date Difference Between Interconnected Tables

Hi,

 

I need to calculate the difference between dates from two different tables. The tricky part is that both date columns (marked with red lines) are kept in tables connected as in the picture below:

purple, blue and green lines represent different sets of key used to connect all of the tables together.

 

I already tried datediff(data1, related(date2),day) method, but it says that tables need to be connected. As you can see, they are but not directly. 

 

May I ask for your assistance on this? 

2 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Danielnir Maybe:

    Measure =
      VAR __Date1 = MAX('SOPOrderReturn'[RequestedDeliverDate])
      VAR __Date2 = MAX('SOPInvoiceCredit'[DocumentDate]
    RETURN
      ( __Date1 - __Date2 ) * 1.
    • Danielnir's avatar
      Danielnir
      Helper II

      Should I mention that I have something around 23k dates to compare? That's just comparing the highest date from one to the highest date from the second. My bad, I wasn't precise enough. Also tried changing MAX to SELECTEDVALUE but it resulted in a blank column...