Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.
I need to calculate the difference between two dates between two tables. The problem is the two tables have a many-to-many relationship.
Date #1: TaskAnalysis.TaskPlanEndDate (Project X will have multiple "end dates", but they are all the same)
Date #2: ProjectList.ContractEndDate (Project X will have 1 end date)
I tried creating this formula:
Solved! Go to Solution.
Hi @Anonymous ,
Try the following formula:
Column =
DATEDIFF(
'TaskAnalysis'[TaskPlanEndDate],
LOOKUPVALUE( ProjectList[ContractEndDate], ProjectList[Project], TaskAnalysis[Project] ),
DAY
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If anyone else can help, I would appreciate it. I am just looking for how to use DAX to accomplish DATEDIFF between two tables with a many-to-many relationship.
Hi @Anonymous ,
Try the following formula:
Column =
DATEDIFF(
'TaskAnalysis'[TaskPlanEndDate],
LOOKUPVALUE( ProjectList[ContractEndDate], ProjectList[Project], TaskAnalysis[Project] ),
DAY
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have the same issue as above, different context but same issue between two tables. I have no way to get around the many-to-many relationship in this case.
I tried the solution listed but it did not work for me. Formula listed below as well as error information.
@Anonymous You can't use RELATED with many-to-many relationships. You will need to use things like MAXX(FILTER...) or LOOKUPVALUE, etc.
@Greg_Deckler Correct, that's what I had said in my post originally. I am trying to figure out how to "use things like MAXX(FILTER...) or LOOKUPVALUE, etc." instead - I've never used anything like this.
@Anonymous Only way to know for sure is sample data:
Sorry, having trouble following, can you post sample data as text and expected output?
Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882
Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.