Forum Discussion
Date Difference between dates from multiple tables
- 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!
Hi Anonymous ,
Why there is no data about 5268910 in your expected result?How to match "Product" and "Task Type"?
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
- Anonymous5 years agoNot applicable
v-kelly-msft as the data has the filters, basically 5268910 is excluded by the filter, therefore, the result will contain blank values for date diff.
- v-kelly-msft5 years agoCommunity Support
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!