Forum Discussion
Anonymous
5 years agoNot applicable
Date Difference between dates from multiple tables
HI, I have 2 tables ( Orders, Tasks) with relationship Many-to-Many and Single Direction Filter, from Tasks=>Orders. I need to calculate the difference between Order Date and the Task date. I...
- 5 years ago
Hi Anonymous,
First create 3 slicer tables as below:
ID slicer = VALUES('Tasks Table'[User ID])Product slicer = VALUES('Orders Table'[Product])Type slicer = VALUES('Tasks Table'[Task Type])Then create 4 measures as below:
_Product = CALCULATE(MAX('Orders Table'[Product]),'Orders Table'[Product] in FILTERS('Product slicer'[Product]))_User ID = CALCULATE(MAX('Orders Table'[User ID]),'Orders Table'[User ID] in FILTERS('ID slicer'[User ID]))_Task date = CALCULATE(MAX('Tasks Table'[Task Date]),FILTER('Tasks Table','Tasks Table'[User ID]=[_User ID]&&'Tasks Table'[Task Type] in FILTERS('Type slicer'[Task Type])))_Diff = var _diff= DATEDIFF([_Task date],MAX('Orders Table'[Order Date]),DAY) Return IF(_diff<=1,_diff&" day",_diff&" days")And you will see:
For the related .pbix file,pls see attached.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
amitchandak
5 years agoSuper User
Anonymous , You need to have a common user ID table.
Then you can have
datediff(min(orders[Order Date]), max(Tasks[task Date]), Day)
refer
Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.