Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

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.

 

koray_0-1634041544467.png

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,

1 ACCEPTED SOLUTION

Try this:

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

 

Output:

VahidDM_0-1634106897196.png

 

 

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

Appreciate your Kudos!!

 

View solution in original post

11 REPLIES 11
VahidDM
Super User
Super User

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
Not applicable

Hello @VahidDM 

 

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

koray_0-1634100941365.png

 

Miro Tarih2 =
LOOKUPVALUE (Miro[Fatura Tarihi],Miro[Fatura Tarihi],'Detailed DED Analysis'[DocumentDate]
)
-MAX('Detailed DED Analysis'[DocumentDate])

Hi @Anonymous 

 

Is there any relashionship between your tables?

Can you share a sample of your data?

 

Appreciate your Kudos!!

 

Anonymous
Not applicable

Hello @VahidDM 

 

deleted.

 

Thank you!

@Anonymous 

 

Each Document Number in Miro table has many dates, which onr do you want to use in the calculation?

 

Appreciate your Kudos!!

 

Anonymous
Not applicable

Hi @VahidDM 

 

I want the calculate to be like this: Detailed DED Analysis'[DocumentDate] - Miro[Fatura Tarihi]

(first Fatura Tarihi dates) that is, the earliest "Fatura Tarihi" belongs to that Document number. @VahidDM 

 

like this:

koray_0-1634106805495.png

 

 

 

Try this:

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

 

Output:

VahidDM_0-1634106897196.png

 

 

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

Appreciate your Kudos!!

 

Anonymous
Not applicable

Thank you so much @VahidDM 
Seems to be working fine. But I couldn't understand why it gives a different result in the crossed out one in the picture below.

 

koray_0-1634107366492.png

 

@Anonymous 

 

Because of the different aggregation you set for that column (for e.g. Earlier) and the MAX formula you used in the measure.

 

Appreciate your Kudos!!

 

Anonymous
Not applicable

Hello @VahidDM 
Is it possible to add filter as positive and negative to maesur results?

koray_0-1634113764731.png

 

 

Anonymous
Not applicable

@VahidDM  Yes you are right. Thank you so much 🙂

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.