XLOOKUP to table with two date columns for date search-range

I’m trying to user XLOOKUP to pull data from a table with two data fields(Beginning Term/Ending Term). I’ve search the community and can’t seem to find the solution.


This example is only using one field, but the two fields - beginning and ending date - are needed.





Thank you for any help you can provide.


[Re-Titled by Moderator]

iPad Pro (1st generation)

Posted on Jan 10, 2025 8:14 PM

Reply
2 replies

Jan 13, 2025 2:59 PM in response to NLoyd

Here's the thing with your data - you don't need to do multiple lookups.


XLOOKUP() contains a parameter telling it how to perform a lookup, such as 'exact match', 'exact or next largest, etc.


In this case, since your dates are all inclusive and there are no gaps, you can simply lookup either:


a) the last president whose start date is smaller than the target date (meaning he was the last one inaugurated)

or

b) the first president whose end date is smaller than the target date


By definition, the end of one presidency is the beginning of another, so there's never a case where dates could overlap:


Cell A4 =XLOOKUP($A2,POTUS::C,POTUS::D,"not found",1,-1)


Fill down.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

XLOOKUP to table with two date columns for date search-range

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.