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

Be 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

Reply
apmulhearn
Helper III
Helper III

Help with Join with Date-Specific Contingencies

Hello!

 

I have two tables.

 

I need to join them for attribution purposees.

These are the criteria I need to be true:

1. Inquiries are joined on Client ID between tables

2. Inquiries are associated with closest First_Payment_Date which is NOT AFTER that Date

 

 

Table 1: Inquiries   
     
Created_OnSubjectMediumCampaignClient_ID
1/1/2015AfricaHubspotEmail12345
3/1/2015IndiaFacebookDiscount12345
4/1/2015KenyaInstagramGiraffe12345
7/1/2017TanzaniaFacebookZebra12345
8/1/2017BotswanaEmailThanksgiving12345

 

Table 2: Guests 
   
Client_IDBooking_NameFirst_Payment_Date
12345Clients_First_Booking6/1/2015
12345Clients_Second_Booking10/1/2017

 

Goal Result Table     
       
Created_OnSubjectMediumCampaignClient_IDBooking_NameFirst_Payment_Date
1/1/2015AfricaHubspotEmail12345Clients_First_Booking6/1/2015
3/1/2015IndiaFacebookDiscount12345Clients_First_Booking6/1/2015
4/1/2015KenyaInstagramGiraffe12345Clients_First_Booking6/1/2015
7/1/2017TanzaniaFacebookZebra12345Clients_Second_Booking10/1/2017
8/1/2017BotswanaEmailThanksgiving12345Clients_Second_Booking10/1/2017

 

 

Many thanks for any help in doing this!

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@apmulhearn 

you can use DAX to create two columns

Booking_name = 
var _date=MINX(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]>Inquiries[Created_On]),Guests[First_Payment_Date])
return maxx(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]=_date),Guests[Booking_Name])

First_payment_Date = 
var _date=MINX(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]>Inquiries[Created_On]),Guests[First_Payment_Date])
return maxx(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]=_date),Guests[First_Payment_Date])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

7 REPLIES 7
apmulhearn
Helper III
Helper III

@ryan_mayu - you gave me exactly what I asked, thank you, and I marked it as a solution.

 

I realize though that I need to take it a step more. I believe I need a measure but I'm a little stuck as to what it is.

The image below is using Inquires[Booking_Name} and Charting it under other Inquiries fields.  

 

The three lines with the blue dots are the same Inquiries[Booking_Name] line because it is associated with 3 different Inquiries. 

I would like it only to highlight the one with the earliest Inquiries [Created Date] (not used in the graphic). Can you help me here?

 

apmulhearn_0-1630474503071.png

 

@apmulhearn 

could you pls share the pbix file after removing the sensitive data?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




It is loaded with sensitive data and will take me a bit of time to remove, but you are helping me, so I will gladly do it!

 

In the meantime, though, I think I can exemplify it based on the small sample you helped me with above. If this doesn't help I will circle back asap.


apmulhearn_1-1630480395911.png

 

apmulhearn_2-1630480421948.png

 

 

@apmulhearn 

why not use the opposite way to search data? searching from Inquiries table instead of searching from guest table.

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @ryan_mayu 

 

Thank you for the suggestion to you Guest instead of Inquiry. Unfortunately, there are (potentially) multiple items on each of those tables. That is, there are multiple Guests assoiciated with a booking, and multiple Inquiries associated with a booking.  

 

I substituted "Campaign" for "Medium" to achieve the second level of drill-down data I need (Medium for me is Marketing Platform, Campaign is Marketing Item.). In doing so, since there were multiple guests on George's 2022 booking, he gets lumped in with two different Marketing Campaigns - he and his wife each clicked one. I want to know which was clicked first and attribute ONLY there.

 

apmulhearn_0-1630488157410.png

 

@apmulhearn 

I think I still need you to provide me some dummy data and the expected output.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@apmulhearn 

you can use DAX to create two columns

Booking_name = 
var _date=MINX(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]>Inquiries[Created_On]),Guests[First_Payment_Date])
return maxx(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]=_date),Guests[Booking_Name])

First_payment_Date = 
var _date=MINX(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]>Inquiries[Created_On]),Guests[First_Payment_Date])
return maxx(FILTER(Guests,Guests[Client_ID]=Inquiries[Client_ID]&&Guests[First_Payment_Date]=_date),Guests[First_Payment_Date])

1.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.