Since our data is sorted in ascending order by Start Date, we can use an optional argument to perform a “reverse lookup” so we stop on the last instance of “Kim West” (we’re actually stopping on the first encountered item in the list when you search from the bottom-up.)
We will copy the formula we used to discover Division and paste it below the Current Division heading. The formula requires the following modification:
=XLOOKUP(A5, MD!$D$5:$D$37, MD!$B$5:$B$37, "Not Found", 0, -1)
The logic of the additional arguments works like so:
=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])
NOTE: The two additional arguments are optional, hence the square brackets.
- [if_not_found] – is what to display if no match exists (e. text message or default value)
- [match_mode] – specifies the Match Type. (0 = Exact match {default}, -1 = Exact match or next smaller, 1 = Exact match or next larger, 2 = Wildcard match)
- [search_mode] – specifies the Search Mode. (1 = Search first to last {default}, -1 = Search last to first, 2 = Binary search {ascending}, -2 = Binary search {descending})
In our case, we are performing an exact match (0) from the last record to the first record (-1) and we will display a message (“Not Found”) if there is not a match .
We see that “Kim West” began her employment working in the “Utility” Division, but currently resides in the “Game” Division.