cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper V

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,

1 ACCEPTED SOLUTION
Super User

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.

11 REPLIES 11
Super User

Hi @koray

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.

Helper V

Hello @VahidDM

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])
Super User

Hi @koray

Is there any relashionship between your tables?

Can you share a sample of your data?

Helper V

Hello @VahidDM

deleted.

Thank you!

Super User

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

Helper V

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:

Super User

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.

Helper V

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.

Super User

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

Helper V

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

Helper V

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

Announcements

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors