cancel
Showing results for 
Search instead for 
Did you mean: 
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

Accepted Solutions
Community Support
Community Support

Re: Linking tables on date

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
Community Support
Community Support

Re: Linking tables on date

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

Benegade
Regular Visitor

Re: Linking tables on date

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
‘Better Together’ T-Shirt Contest – Winner Announced!

‘Better Together’ T-Shirt Contest – Winner Announced!

And the winner is...

Announcing the New Spanish Forum

Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

April 2020 Community Highlights

April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

MBAS Gallery 2020

MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors