There's an operation I have to calculate and I'm unsure as to how I should execute that and would need some suggestion:
Data Set A
Customer ID | Interaction Date | Product Reference
123 | 08 Jan 2020 | X
456 | 19 Dec 2019 | Y
Data Set B
Product Reference | Service Period Start | Service Period End | Service Reference
X | 1 April 2019 | 31 December 2019 | SR777
X | 1 January 2020 | 31 March 2020 | SR888
Y | 1 April 2019 | 31 December 2019 | SR666
Y | 1 January 2020 | 31 March 2020 | SR555
Objective
For each customer in Data Set A, I want to look up the corresponding Product Reference in Data Set B, then compare Data Set A Interaction Date to Data Set B Service Period Start and End so that Interaction Date is between Start and End, and return the corresponding Service Reference.
Current Method:
- Left join B to A on Product Reference.
- Conditional Function AND(Service Period Start < Interaction Date, Service Period End > Service Period End) to return TRUE or FALSE.
- Filter TRUE
Is this the right approach or do you have a more powerful tool for this? I'm worried about the the explosion of data on the Join step.