Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Date Difference between 2 different tables

Hello,

 

I want calculate Date Difference between 2 different tables. I think I did but i have two problem.

1-) that but it gives wrong result when calculating same days.

 

I use this: 

Miro Tarih = DATEDIFF(MAXX(RELATEDTABLE(Miro),Miro[Fatura Tarihi].[Date]),'Detailed DED Analysis'[DocumentDate].[Date],DAY)
 
2-) I also want to do the subtraction in reverse, but I couldn't.
I want the calculate to be like this: Detailed DED Analysis'[DocumentDate] - Miro[Fatura Tarihi]
not like this: Miro[Fatura Tarihi] - Detailed DED Analysis'[DocumentDate]



Regards,

  • VahidDM's avatar
    VahidDM
    4 years ago

    Try this:

    Measure = DATEDIFF(max('Detailed DED Analysis'[DocumentDate]),max(Miro[Fatura Tarihi]),DAY)

     

    Output:

     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!!

     

11 Replies

  • Hi Anonymous 

     

    Try this if there is a relationship based on the DocumentNumber between those 2 tabels:

    Miro Tarih =
    LOOKUPVALUE (
        Miro[Fatura Tarihi],
        Miro[DocumentNumber], Detailed DED Analysis[DocumentNumber]
    )
        - MAX ( Miro[DocumentNumber] )

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

    Appreciate your Kudos!!

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello VahidDM 

       

      Thank you for reply. 
      It did not happen. Or I did something wrong 😞

       

      Miro Tarih2 =
      LOOKUPVALUE (Miro[Fatura Tarihi],Miro[Fatura Tarihi],'Detailed DED Analysis'[DocumentDate]
      )
      -MAX('Detailed DED Analysis'[DocumentDate])
      • VahidDM's avatar
        VahidDM
        Super User

        Hi Anonymous 

         

        Is there any relashionship between your tables?

        Can you share a sample of your data?

         

        Appreciate your Kudos!!