March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello. I have searched the forums and cannot find a solution that works for my case. Please take a look at the problem below. I promise to send kudos and accept solutions.
I have two tables that I need to calculate the difference between and they are related through a third table (see entity relationship below).
I need to calculate the days difference between tables 1 and 2. The key for each of these tables is in table 3 (that is the only way I can connect them). Below is my expected output.
I would appreciate any help or solutions you could offer.
@parry2k @Ritaf1983 @amitchandak @Ashish_Mathur if you're available.
Solved! Go to Solution.
Hi @chonchar ,
Thank you for @Ashish_Mathur answer.
Below is my table1:
Below is my table2:
Below is my table3:
The following DAX might work for you:
Days Difference1 =
VAR DateFromTable1 = CALCULATE(MINX('Table1',Table1[approved date]), RELATEDTABLE('Table'))
VAR DateFromTable2 = CALCULATE(MAX(Table2[Creation date]), RELATEDTABLE('Table'))
RETURN
DATEDIFF(DateFromTable1, DateFromTable2, DAY)
The final output is shown in the following figure:
The reason for the incorrect values is mainly because the relationships are not known how they are paired, please send your relationship pairing chart in detail as the correct pairing of the relationships can make a big difference in the results.
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @chonchar ,
Thank you for @Ashish_Mathur answer.
Below is my table1:
Below is my table2:
Below is my table3:
The following DAX might work for you:
Days Difference1 =
VAR DateFromTable1 = CALCULATE(MINX('Table1',Table1[approved date]), RELATEDTABLE('Table'))
VAR DateFromTable2 = CALCULATE(MAX(Table2[Creation date]), RELATEDTABLE('Table'))
RETURN
DATEDIFF(DateFromTable1, DateFromTable2, DAY)
The final output is shown in the following figure:
The reason for the incorrect values is mainly because the relationships are not known how they are paired, please send your relationship pairing chart in detail as the correct pairing of the relationships can make a big difference in the results.
Best Regards,
Xianda Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous this works perfectly. Thank you very much.
Hi,
Share data in a format that can be pasted in an MS Excel file. Show the expected result very clearly.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
125 | |
85 | |
69 | |
54 | |
45 |
User | Count |
---|---|
204 | |
105 | |
99 | |
64 | |
54 |