Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RoyalJ
New Member

Date Diff on Different tables with multiple date values

Hi,

 

I have seen others ask something similar to this but not the exact issue I am facing. I have a large data model with different information about sales to clients. In one table I have he information about the party (party ID, Join_Date etc) and in another table I have Trade info (Party ID,Trade ID, Trade Date). I want to create a Date Diff column that measures the time between their first Join and their first Trade (people can have multiple accounts multiple (join_dates and trade dates)).

 

The issue also seems to be that they can have multiple first join and trade dates if they opened the accounts and made the trades at once. I will try to show this below also.

 

 

Party Table

Party IDAccount IDJoin Date
11A01/01/2024
11B01/01/2024
11C07/01/2024
11D11/01/2024
22A02/01/2024
22B02/01/2024
33A07/01/2024

 

 

Trade Table

Party IDAccount IDTrade DateTrade ID
11A04/01/2024sdadasd
11B09/01/2024feefeww
11C11/01/2024fw43gg4
11D11/01/2024g4343ttrw
22A08/01/202443g34g4
22B08/01/2024g5jh67jj
33A25/01/202434g35ztg

 

I have tried performing the measure 

Diff = DATEDIFF(MIN(PARTY[JOIN_DATE]), TRADE[TRADE_DATE], DAY)

 

However I find this only works contextually and doesnt work as a filter within another measure nor as a slicer (only as a filter on a table visual)

 

Thanks in advance

2 ACCEPTED SOLUTIONS
lbendlin
Super User
Super User

Your Account ID seems to be a primary key.  Create an Account dimension that lists the Account IDs and then control both of your fact tables from that dimension.  Then the measures write themselves.

View solution in original post

Anonymous
Not applicable

Hi @RoyalJ 

 

Thanks to @lbendlin  for your prompt reply. Here are my additions:

 

Measure does not work as a slicer, but it can be put into Filters on this visual, I'm just not sure what kind of filtering you need to do, we are better able to help you if you can provide more information.

 

Here is the testing I've done so far.

 

Create another Measure to filter out IDs with datediff > 5 days

 

>5 = CALCULATE(MAX([Trade ID]), FILTER(Trade, [Diff] > 5))

 

 

Output:

vxuxinyimsft_0-1709885483136.png

 

Or put the Diff into a visual level filter for filtering.

vxuxinyimsft_1-1709885613550.png

 

If I've misunderstood you, please provide the results you are hoping for: How to provide sample data in the Power BI Forum - Microsoft Fabric Community . Or show it as a screenshot or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @RoyalJ 

 

Thanks to @lbendlin  for your prompt reply. Here are my additions:

 

Measure does not work as a slicer, but it can be put into Filters on this visual, I'm just not sure what kind of filtering you need to do, we are better able to help you if you can provide more information.

 

Here is the testing I've done so far.

 

Create another Measure to filter out IDs with datediff > 5 days

 

>5 = CALCULATE(MAX([Trade ID]), FILTER(Trade, [Diff] > 5))

 

 

Output:

vxuxinyimsft_0-1709885483136.png

 

Or put the Diff into a visual level filter for filtering.

vxuxinyimsft_1-1709885613550.png

 

If I've misunderstood you, please provide the results you are hoping for: How to provide sample data in the Power BI Forum - Microsoft Fabric Community . Or show it as a screenshot or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.

 

Best Regards,
Yulia Xu

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

Your Account ID seems to be a primary key.  Create an Account dimension that lists the Account IDs and then control both of your fact tables from that dimension.  Then the measures write themselves.

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.