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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Time Intelligence between two Dates from different tables

Hi guys,

 

I have two tables, one table contains a column indicating when a delivery was shipped and the other table contains a column indicating when the requested delivery date was. I would now like to calculate the offset between these columns, but unfortunately this is not possible, because there are two tables. How can I calculate the offset in this example?

I hope you can help me! 😞

 

Abba1234!

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Based on the additional information you have provided regarding the use of a date table believe that the formulas can be the following:

Days = 
VAR Sumary_Table =
    FILTER (
        CROSSJOIN (
            SELECTCOLUMNS (
                Orders;
                "CLient_Key"; Orders[Key],
                "Desidered_date", RELATED('calendar'[Date])
            ),
            SELECTCOLUMNS (
                Delivery,
                "Sales_Key", Delivery[Key],
                "Delivery_date", Delivery[Delivery date]
            )
        ),
        [CLient_Key] = [Sales_Key]
    )
RETURN
    SUMX ( Sumary_Table, DATEDIFF ( [Desidered_date], [Delivery_date], DAY ) )

 

The second option you need to redo the measure to:

Days _ 2 = 
VAR Sumary_Table =
    SUMMARIZE (
        'Delivery (2)',
        'Delivery (2)'[Key],
        'Delivery (2)'[Delivery date],
        'Orders (2)'[Desidered Delivery Date]
    )
RETURN
    SUMX (
        Sumary_Table,
        DATEDIFF ( 'Orders (2)'[Desidered Delivery Date], 'Delivery (2)'[Delivery date], DAY )
    )

 

chehck PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

8 REPLIES 8
parry2k
Super User
Super User

@Anonymous why not create a sample dummy data, you don't need to send the real data. How you expect someone to help you if you can provide the information. Good luck @MFelix 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

MFelix
Super User
Super User

Hi @Anonymous ,

 

How do the two table relate? if they are related bu a delivery ID you can make the calculation.

 

Can you share some more information about your data? Please see this post regarding How to Get Your Question Answered Quickly (courtesy of @Greg_Deckler) and How to provide sample data in the Power BI Forum (courtesy of @ImkeF).


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Hi @MFelix ,

 

yes there is a relation by the delivery ID, but how can i do the calculation? If I try it by measures, it cant find the second table with the column. I unfortunatly cant share the date because of privacy :/.

Hi @Anonymous ,

 

No need for the actual data can you make a mocukp sample? What are the columns on your model, how do they relate?

 

If you want you can share the information trough private message.

 

Has you can imagine without any data is difficult to tell you what is the kind of measure you need to use, depending on the type of relationships, data, etc, the calculations vary.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Anonymous
Not applicable

Here i have a sample for both tables. The connection is by a created column "Key".

Test1.PNG

Test2.PNG

  

Hi @Anonymous ,

 

Based on the additional information you have provided regarding the use of a date table believe that the formulas can be the following:

Days = 
VAR Sumary_Table =
    FILTER (
        CROSSJOIN (
            SELECTCOLUMNS (
                Orders;
                "CLient_Key"; Orders[Key],
                "Desidered_date", RELATED('calendar'[Date])
            ),
            SELECTCOLUMNS (
                Delivery,
                "Sales_Key", Delivery[Key],
                "Delivery_date", Delivery[Delivery date]
            )
        ),
        [CLient_Key] = [Sales_Key]
    )
RETURN
    SUMX ( Sumary_Table, DATEDIFF ( [Desidered_date], [Delivery_date], DAY ) )

 

The second option you need to redo the measure to:

Days _ 2 = 
VAR Sumary_Table =
    SUMMARIZE (
        'Delivery (2)',
        'Delivery (2)'[Key],
        'Delivery (2)'[Delivery date],
        'Orders (2)'[Desidered Delivery Date]
    )
RETURN
    SUMX (
        Sumary_Table,
        DATEDIFF ( 'Orders (2)'[Desidered Delivery Date], 'Delivery (2)'[Delivery date], DAY )
    )

 

chehck PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi,

In the first table, you can use the following calculated column formula

=lookupvalue('table2'[desired delivery date],'table2'[key],'table1'[key])

In another calculated column, you may subtract the 2 dates.

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Anonymous ,

 

Not sure if this matches your model but I have made the following setup:

 

MFelix_0-1609694933240.png

 

Now create the following measure:

Days = 
VAR Sumary_Table =
    FILTER (
        CROSSJOIN (
            SELECTCOLUMNS (
                Client_Number,
                "CLient_Key", Client_Number[Key],
                "Desidered_date", Client_Number[Desidered Delivery Date]
            ),
            SELECTCOLUMNS (
                Sales_Document,
                "Sales_Key", Sales_Document[Key],
                "Delivery_date", Sales_Document[Delivery date]
            )
        ),
        [CLient_Key] = [Sales_Key]
    )
RETURN
    SUMX ( Sumary_Table, DATEDIFF ( [Desidered_date], [Delivery_date], DAY ) )

If your model however is only with the two table related you can do the following measure:

MFelix_3-1609695462296.png

 

 

Days _ 2 =
VAR Sumary_Table =
    SUMMARIZE (
        'Client_Number (2)',
        'Client_Number (2)'[Key],
        'Client_Number (2)'[Desidered Delivery Date],
        "order dates", VALUES ( 'Sales_Document (2)'[Delivery date] )
    )
RETURN
    SUMX (
        Sumary_Table,
        DATEDIFF ( 'Client_Number (2)'[Desidered Delivery Date], [order dates], DAY )
    )

 

Has you can see result is the same in both cases:

 

MFelix_2-1609695447301.png

Check PBIX file attach.

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors