Summary

To perform a two-lookup with the XLOOKUP function (a double XLOOKUP), you can nest one XLOOKUP inside another. In the example shown, the formula in H6 is:

=XLOOKUP(H5,months,XLOOKUP(H4,names,data))

where months (C4:E4) and names (B5:B13), and data (C5:E13) are named ranges.

Generic formula

=XLOOKUP(A1,months,XLOOKUP(A2,names,data))

Explanation 

One of XLOOKUP's features is the ability to lookup and return an entire row or column. This feature can be used to nest one XLOOKUP inside another to perform a two-way lookup. The inner XLOOKUP returns a result to the outer XLOOKUP, which returns a final result.

Note: XLOOKUP performs an exact match by default, so match mode is not set.

Working from the inside out, the inner XLOOKUP is used to retrieve all data for "Frantz":

XLOOKUP(H4,names,data)

XLOOKUP finds "Frantz" in the named range names (B5:B13). Frantz appears in the fifth row, so XLOOKUP returns the fifth row of data (C5:E13). The result is an array representing a single row of data for Frantz, containing 3 months of sales:

{10699,5194,10525} // data for Frantz

This array is returned directly to the outer XLOOKUP as the return_array:

=XLOOKUP(H5,months,{10699,5194,10525})

The outer XLOOKUP finds the value in H5 ("Mar") inside the named range months (C4:E4). The value "Mar" appears as the third item, so XLOOKUP returns the third item from the sales data, the value 10525.

Without named ranges

The named ranges used in this example are for readability only. Without named ranges, the formula is:

=XLOOKUP(H5,C4:E4,XLOOKUP(H4,B5:B13,C5:E13))

INDEX and MATCH

This example can be solved with INDEX and MATCH like this:

=INDEX(C5:E13,MATCH(H4,B5:B13,0),MATCH(H5,C4:E4,0))

INDEX and MATCH is a good solution to this problem, and probably easier to understand for most people. However, the XLOOKUP version shows off the power and flexibility of XLOOKUP.

Dynamic Array Formulas are available in Office 365 only.
Dave Bruns Profile Picture

AuthorMicrosoft Most Valuable Professional Award

Dave Bruns

Hi - I'm Dave Bruns, and I run Exceljet with my wife, Lisa. Our goal is to help you work faster in Excel. We create short videos, and clear examples of formulas, functions, pivot tables, conditional formatting, and charts.