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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Benegade
Regular Visitor

Linking tables on date

Hi,

I am trying to create a report that shows the effect of advertising campaigns on products. i.e. how many units (or in my case, passengers booked) do we sell as the result of an advertising campaign.

I have two main tables which I have simplified for illustration. One table contains the marketing activity – this includes the date of the marketing, the media through which it was advertised, and the destination (product) that was advertised.

The second table contains all bookings, and includes booked date, destination (product), number of passengers booked etc.

What I want to be able to show, is for any given marketing appearance and destination, how many pax booked that destination within 3 days of the marketing appearance date. E.g. if there was a marketing appearance on 1/1/17 for New York, then I want to see all bookings for New York on the 1st, 2nd or 3rd of January 2017 and exclude all others.

The issue I am having is finding a way to link the marketing activity table to the bookings table as there is no unique identifier between the tables.

Any suggestions greatly appreciated.

 

Untitled.png

 

1 ACCEPTED SOLUTION
v-qiuyu-msft
Community Support
Community Support

Hi @Benegade,

 

Assume the sample data below: 

 

q3.PNGq4.PNG

 

You can create a measure like this: 

 

Measure = CALCULATE(SUM('Bookings'[Pax]),FILTER('Bookings',IF(MAX('MarketingActivity'[Appearance Date])<='Bookings'[BookedDate],DATEDIFF(MAX('MarketingActivity'[Appearance Date]),'Bookings'[BookedDate],DAY),BLANK())<3 &&'Bookings'[Destination]=MAX('MarketingActivity'[Destination])))

 

For more information, you can download attached pbix file. If it doesn't meet your requirement, please share some sample data with us and clarify corresponding results. 

 

q5.PNG

 

Best Regards,
Qiuyun Yu 

Community Support Team _ Qiuyun Yu
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
v-qiuyu-msft
Community Support
Community Support

Hi @Benegade,

 

Assume the sample data below: 

 

q3.PNGq4.PNG

 

You can create a measure like this: 

 

Measure = CALCULATE(SUM('Bookings'[Pax]),FILTER('Bookings',IF(MAX('MarketingActivity'[Appearance Date])<='Bookings'[BookedDate],DATEDIFF(MAX('MarketingActivity'[Appearance Date]),'Bookings'[BookedDate],DAY),BLANK())<3 &&'Bookings'[Destination]=MAX('MarketingActivity'[Destination])))

 

For more information, you can download attached pbix file. If it doesn't meet your requirement, please share some sample data with us and clarify corresponding results. 

 

q5.PNG

 

Best Regards,
Qiuyun Yu 

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

Hi @v-qiuyu-msft,

 

Thanks for the reply - that helped a lot.

 

I modified the formula slightly so that it excluded bookings made prior to the marketing date appearance, and found that I needed to replace the blank() with an emptry string because it was viewing blank as 0, but otherwise it worked perfectly.

 

The final formula which seems to be working for me is:

 

Measure = CALCULATE(SUM('Bookings'[Pax]),FILTER('Bookings',
IF(MAX('MarketingActivity'[Appearance Date])<='Bookings'[BookedDate],DATEDIFF(MAX('MarketingActivity'[Appearance Date]), 'Bookings'[BookedDate],DAY),"") <=3
&& IF(MAX('MarketingActivity'[Appearance Date])<='Bookings'[BookedDate],DATEDIFF(MAX('MarketingActivity'[Appearance Date]), 'Bookings'[BookedDate],DAY),"") >=0
&&'Bookings'[Destination]=MAX('MarketingActivity'[Destination])))

 

Kind regards,

Ben

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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