Forum Discussion
Date difference between two different tables
I searched the forums but could not find a solution to my particular issue. I have a date table.
My date table is connected to "date shipped" in my shipped table, and to "order date" in the orders table.
I need to calculate the days difference between date shipped.......but to "request date" in the orders table (not to order date). But my relationship from my date table goes to the "order date" and I cannot change that.
Any help is appreciated!
I tried to create a Data model that can refer to your data model. Please find this pbix, where I created 4 ways how can you get date diff from two different tables.
I created a common dim, Date dim. Common dim for date diff. The date dim just for your ref.
I also populated dates from one table to another to get date diff.
https://www.dropbox.com/s/y47ah38sr157l7t/Oder_delivery.pbix?dl=0
Let me know if this can solve your purpose.
21 Replies
- amitchandakSuper User
If you want to use measure, means run time calc you need ensure that it happens at level
like
datediff = var _order = Min(sales[order_date]) var _Delivery = max(deilvery[Deilvery_date]) //Assume you common order and date dim calculate(sumx(values(order[ID]),datediff([_order],[_Delivery]),DAY)) //OR //calculate(sumx(Order,datediff([_order],[_Delivery],DAY)),values(order[ID]))Another method is to get the date in one table or maybe order dim
New column
Max date in Sales 1 = maxx(filter(deilvery,sales[Order_id] = deilvery[Order_id] ,deilvery[Deilvery_date]))Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin- AnonymousNot applicable
I tried the first method but get an error on the comma (after date shipped).
Remember that these are in two different tables, and that "request date" is not connected to my date table (but it is in the same table as order date).
datediff =var _order = Min(Orders[Request Date])var _Delivery = max('Flu Shipped'[Date Shipped]),- amitchandakSuper User
In the first formula, you do not need date dim, You only need common order dim or some other dim to have line-level diff.
Try second method
- AnonymousNot applicable
Hello,
I am not really following your solutions because you are using completely different table names than my real information.
- amitchandakSuper User
I tried to create a Data model that can refer to your data model. Please find this pbix, where I created 4 ways how can you get date diff from two different tables.
I created a common dim, Date dim. Common dim for date diff. The date dim just for your ref.
I also populated dates from one table to another to get date diff.
https://www.dropbox.com/s/y47ah38sr157l7t/Oder_delivery.pbix?dl=0
Let me know if this can solve your purpose.
- Ashish_MathurSuper User
Hi,
Take a simple example and show the expected result.
- AnonymousNot applicable
Due Date Shipped Date Days Early/Late
Jan 10 2020 Jan 15 2020 5
Jan 12 2020 Jan 09 2020 -3
- amitchandakSuper User
Anonymous
Please check the solution in file, if that can help https://www.dropbox.com/s/y47ah38sr157l7t/Oder_delivery.pbix?dl=0