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

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.

Reply
Anonymous
Not applicable

Date diff between related tables

Hello, 

 

I have what is no doubt a simple query. I am trying to calulate the datediff between two dates in relared tables. The problem is complicated (maybe) by the use of a bridge table to link the tables and multiple rows to filter on one of the tables.

 

The structure is like this

 

Client Application  
Client Record IDApplication dateOutcome Date
110/02/202005/05/2020
215/01/202004/05/2020
301/03/202008/05/2020
202/02/202003/05/2020
   
Bridge Table  
Client Record ID (Unique)  
1  
2  
3  
   
   
Client Interactions  
Client record IDDate of interactionInteraction type 
101/03/2020complaint 
203/03/2020complaint 
208/02/2020complaint 
301/04/2020compliment
301/05/2020complaint 

 

What i would like to calulate is the length of time from the clients first complaint to their eventual application outcome. 

 

I was trying to do this by bringing in the first interacion date as a column on the main application table and then doing datediff to calculate the difference between the first interaction and the outcome. The problem is however, that i  need to bring the first complaint. So i tried to do this with the following formula

 

First complaint = CALCULATE(min('Client interaction - Rows'[Date of session / Activity].[Date]),filter('Client interaction - Rows','Client interaction - Rows'[Type]="complaint")
 
but this just provides the first complain for any client against all rows.  Any tips on this? 
 
Thanks a lot 
 
DD
 
 
5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Create a column

first date =
CALCULATE (
    MIN ( 'Client Interactions'[Date of interaction] ),
    FILTER (
        ALLEXCEPT (
            'Client Interactions',
            'Client Interactions'[Client record ID]
        ),
        'Client Interactions'[Date of interaction] >= 'Client Application'[Application date]
            && 'Client Interactions'[Date of interaction] <= 'Client Application'[Outcome Date]
            && 'Client Interactions'[Interaction type ] = "complaint"
    )
)

Capture17.JPG

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Dear Maggie, 

 

Thanks for your response. It needs a bit of tweaking I think. The solution will only provide the first interaction if the outcome date is present, also it seems to pull in those that don't match the interaction criteria "complaint". 

 

I was confused also about the syntax. My understanding was that the filter(allexcept(client record id) would return the min interaction date for each individual client and I would just need to combine this with something that asked to do this only when the interaction type matched complaint. So i wasn't sure why we needed to also filter between application and outcome dates also?

 

Thanks

 

 

 

 

Hi @Anonymous 

So what is the correct result for your data example?

And what would be if outcome date is not there?

 

Best Regards

Maggie

parry2k
Super User
Super User

@Anonymous do you want to see each application of the client, I noticed there are two application for some of the client ?



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Anonymous
Not applicable

Hi,

 

Thanks for looking into this.

 

yeah, each applicaiton will have a unique reference which ties to all interactions as well as outcomes.

 

So i'm looking for the date between the earliest date of complaint to the outcome for each applicaiton unique ID.

 

Hopefully that makese sense?

 

thansk

 

Euan

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.