Lookup date equal to or less than given date with multiple criteria
I've been struggling with this problem for a while now. Googling around has gotten me close but not quite there yet.
I have two sheets, 'Leave Detail' and 'Unpaid Leave'.
A unique identifier for each employee is in column A on each sheet. Each report has a start date and an end date.
Problems: The leave dates in the 'Leave Detail' sheet can span multiple days. They can also be only part days - Having a combined date and time in the Start and End columns. There can also be multiple entries (typically no more than two, and more than one is not terrible common) for the same date.
I need to lookup the 'Leave Type' in column E and 'Comment' in column H from 'Leave Detail' and return it against the corresponding leave in the 'Unpaid Leave sheet'.
Scenario:
Team Member A takes planned leave for 01/01/2019 to 02/01/2019.
Team Member A is unpaid for 3.5 hours on 02/01/2019 as they had insufficient leave balance available.
I need the unpaid leave record in 'Unpaid Leave' to return the leave type and comment from 'Leave Detail'.
I've tried a mix of approximate lookup with sorted sheets and arrayed 'MAX' formulas to no avail...
I did have the sheet working with just returning matches based on the same start date and employee ID, but it requires manual matching of leave that spans more than one day.
Suggestions welcome!
Example sheet attached below:
https://docs.google.com/spreadsheets/d/1b_RCNUjdb922h6J03pMev4HcYlIDk0fk1CBffQ53dQo/edit?usp=sharing
Edit: updated to correct link
Posted Jan 24, 2019, 1:27 PM UTC · edited
This is the exact same problem I just solved 2 days ago. I used VBA. I simply stopped trying to use regular formulas when I reached 100 characters of formula. It got unreadable.
Let me know if VBA is in the scope and I'll share the code.