Double Xlookup

A double XLOOKUP, also known as a two way XLOOKUP, is a powerful formula technique available in both Excel and Google Sheets that allows you to search for data across both rows and columns simultaneously. Think of it as a two-dimensional lookup that finds the intersection point between a row criterion and a column criterion, similar to reading a multiplication table where you match both the row and column to find your answer.

Understanding XLOOKUP Basics

Before diving into double XLOOKUP, it’s important to understand the standard XLOOKUP function. Introduced in Excel in 2019 and added to Google Sheets in 2022, XLOOKUP is a modern replacement for VLOOKUP and HLOOKUP. The basic syntax is:

=XLOOKUP(lookup_value, lookup_array, return_array, [if_not_found], [match_mode], [search_mode])

This function searches for a value in one direction (either vertically or horizontally) and returns a corresponding result. It’s more flexible and powerful than its predecessors, with built-in error handling and the ability to search in any direction. The function works identically in both Excel and Google Sheets, making it easy to transfer your formulas between platforms.

The Difference Between Single and Double XLOOKUP

A single XLOOKUP performs a one-dimensional lookup, searching through a single row or column to find a match. A double XLOOKUP, however, nests two XLOOKUP functions together to create a two-dimensional lookup system. The outer XLOOKUP searches vertically (or horizontally), while the inner XLOOKUP searches in the perpendicular direction, allowing you to pinpoint exact data at the intersection of two criteria.

When to Use a Two Way XLOOKUP

Two way XLOOKUP is ideal for situations where your data is organized in a matrix or table format with both row and column headers. Common use cases include:

  • Price matrices where products are listed in rows and size/color options in columns
  • Employee schedules with names in rows and dates in columns
  • Sales data with regions in rows and months in columns
  • Inventory systems with product codes in rows and warehouse locations in columns
  • Grade books with student names in rows and assignment names in columns

How Does Double XLOOKUP Work for Two-Dimensional Lookups?

The magic of double XLOOKUP lies in its nested structure. The inner XLOOKUP function runs first, returning an entire array of values. The outer XLOOKUP then searches within that returned array to find your final result.

The Syntax of Nested XLOOKUP Functions

The general formula structure for a double XLOOKUP is:

=XLOOKUP(vertical_lookup, vertical_array, XLOOKUP(horizontal_lookup, horizontal_array, data_range))

Breaking this down:

  • The inner XLOOKUP searches horizontally to identify which column you need
  • It returns an entire column of data from your data range
  • The outer XLOOKUP then searches vertically within that returned column
  • The final result is the value at the intersection point

Lookup Arrays in Two Way XLOOKUP

In a two way XLOOKUP, you work with two separate lookup arrays:

The horizontal lookup array contains your column headers (like months, product sizes, or dates). The vertical lookup array contains your row headers (like employee names, product categories, or regions). These arrays must be single rows or columns that correspond to the headers in your data table.

Return Arrays and How They Function

The return array in a double XLOOKUP is your entire data range, excluding the headers. When the inner XLOOKUP executes, it returns a complete column from this range. The outer XLOOKUP then searches within that returned column to extract the specific value you need. This two-step process is what enables the two-dimensional lookup capability.

How Do You Create a Double XLOOKUP Formula Step-by-Step?

Let’s walk through building a double XLOOKUP formula using a practical example: a price matrix where different products have different prices based on their size.

Setting Up Your Data for Two Way Lookup

Proper data organization is crucial for double XLOOKUP success. Your table should have:

  • Row headers in the leftmost column (Product names: Shirt, Pants, Jacket)
  • Column headers in the top row (Sizes: Small, Medium, Large, XL)
  • Data values in the interior cells (Prices corresponding to each product-size combination)
  • No merged cells or gaps in your data structure

Writing the First XLOOKUP Function

Start with the inner XLOOKUP, which will search horizontally across your column headers. If your sizes are in row 1 from B1 to E1, and your prices are in B2:E4:

=XLOOKUP("Medium", B1:E1, B2:E4)

This formula searches for “Medium” in the header row and returns the entire “Medium” column of prices. Test this formula alone first to ensure it returns the correct column of data.

Nesting the Second XLOOKUP Function

Now wrap this inner XLOOKUP with an outer XLOOKUP that searches for your product. If your product names are in A2:A4:

=XLOOKUP("Shirt", A2:A4, XLOOKUP("Medium", B1:E1, B2:E4))

The outer XLOOKUP searches for “Shirt” in the product column and looks for it within the array returned by the inner XLOOKUP (the Medium column). This gives you the price for a Medium Shirt.

Testing Your Double XLOOKUP Formula

Replace the hardcoded lookup values with cell references for flexibility:

=XLOOKUP(G2, A2:A4, XLOOKUP(H2, B1:E1, B2:E4))

Where G2 contains your product name and H2 contains your size. Test various combinations to verify the formula returns correct results. Check edge cases like the first and last items in your rows and columns.

What Are Some Practical Examples of Double XLOOKUP?

Example 1: Price Matrix Lookup

Imagine you run an online clothing store with varying prices based on product type and size:

         Small  Medium  Large   XL
Shirt    $20    $22     $24     $26
Pants    $35    $38     $42     $45
Jacket   $60    $65     $70     $75

Your double XLOOKUP formula would be: =XLOOKUP(F2, A2:A4, XLOOKUP(G2, B1:E1, B2:E4))

When a customer selects “Pants” and “Large”, the formula instantly returns $42. This eliminates manual lookup errors and speeds up your pricing process significantly.

Example 2: Employee Data Retrieval Across Multiple Criteria

HR departments often need to find specific information about employees based on multiple criteria. Consider a work schedule where rows represent employees and columns represent dates:

           Mon    Tue    Wed    Thu    Fri
Alice      8-4    OFF    8-4    8-4    8-4
Bob        9-5    9-5    9-5    OFF    9-5
Charlie    OFF    8-4    8-4    8-4    8-4

Formula: =XLOOKUP("Bob", A2:A4, XLOOKUP("Wed", B1:F1, B2:F4))

This returns “9-5”, showing Bob’s Wednesday schedule. HR can quickly check any employee’s schedule for any day without scrolling through large spreadsheets.

Example 3: Inventory Management with Two Way XLOOKUP

Warehouse managers tracking inventory across multiple locations can use double XLOOKUP to quickly find stock levels. With products in rows and warehouse locations in columns:

              NYC    LA     Chicago  Miami
Widget A      150    200    175      125
Widget B      300    250    290      310
Widget C      75     100    85       90

Formula: =XLOOKUP("Widget B", A2:A4, XLOOKUP("Chicago", B1:E1, B2:E4))

This immediately shows that Widget B has 290 units in the Chicago warehouse, enabling faster decision-making for stock transfers and reorders.

How Does Double XLOOKUP Compare to Other Two Way Lookup Methods?

Double XLOOKUP vs INDEX MATCH MATCH

Before XLOOKUP became available in Excel and Google Sheets, the INDEX MATCH MATCH combination was the go-to method for two-dimensional lookups:

=INDEX(B2:E4, MATCH("Shirt", A2:A4, 0), MATCH("Medium", B1:E1, 0))

While this works in both platforms, double XLOOKUP offers several advantages:

  • More intuitive syntax that’s easier to read and understand
  • Built-in error handling with the if_not_found argument
  • Better performance with large datasets due to modern optimization
  • Easier to modify and troubleshoot

However, INDEX MATCH MATCH may still be necessary if you’re working with older Excel versions (pre-2019) or if you need compatibility with users who haven’t updated their Google Sheets to include XLOOKUP functionality.

Two Way XLOOKUP vs Traditional VLOOKUP Combinations

Some users attempt two-dimensional lookups using nested VLOOKUPs, but this approach is extremely limited. VLOOKUP can only search leftward, requires column index numbers that break when columns are inserted, and becomes complicated quickly. Double XLOOKUP eliminates all these pain points with its flexible search direction and array-based return values.

Performance Considerations for Large Datasets

For datasets with thousands of rows and columns, performance becomes important. Double XLOOKUP is generally efficient in both Excel and Google Sheets, but consider these optimization tips:

  • Use exact match mode (the default) rather than approximate match when possible
  • Keep your lookup arrays as compact as possible
  • Avoid volatile functions in combination with XLOOKUP
  • In Excel, consider using Tables (Ctrl+T) for structured references; in Google Sheets, use named ranges
  • Google Sheets users should note that very large formulas may recalculate slower than in Excel

For datasets exceeding 100,000 cells, test your formula performance and consider alternative approaches like Power Query (Excel) or Google Sheets’ QUERY function if lookup times become problematic.

What Are Common Errors and How Do You Troubleshoot Double XLOOKUP?

#N/A Errors in Two Way XLOOKUP

The #N/A error indicates that XLOOKUP couldn’t find your lookup value. In double XLOOKUP, this can occur in either the inner or outer function. To diagnose:

  1. Test the inner XLOOKUP independently by entering it alone in a cell
  2. If it works, the problem is with the outer XLOOKUP’s search value
  3. Check for extra spaces, different capitalization, or data type mismatches
  4. Verify that your lookup value actually exists in your lookup array

Common causes include trailing spaces in text values, numbers stored as text, or lookup values that don’t exactly match the header values.

Handling Missing Values with If_not_found Argument

You can gracefully handle missing values by using XLOOKUP’s fourth argument:

=XLOOKUP(G2, A2:A4, XLOOKUP(H2, B1:E1, B2:E4, "Size not found"), "Product not found")

This nested error handling ensures your spreadsheet displays user-friendly messages instead of #N/A errors. You can customize these messages to guide users: “Please check product name” or “Size unavailable” provides better context than a cryptic error code.

Debugging Nested XLOOKUP Formulas

When your double XLOOKUP isn’t working, use these debugging strategies:

  1. Formula Evaluate: Press F9 after highlighting the inner XLOOKUP to see what array it returns
  2. Break it apart: Test each XLOOKUP separately in different cells
  3. Check references: Ensure your arrays include all necessary data without extra blank rows/columns
  4. Verify data types: Use the TYPE function to confirm numbers are numbers and text is text
  5. Watch for absolute references: Use $ appropriately when copying formulas (e.g., $B$1:$E$1)

What Are Advanced Tips for Mastering Double XLOOKUP?

Combining Double XLOOKUP with Other Excel Functions

Supercharge your double XLOOKUP by combining it with other functions:

With IF: =IF(G2="", "", XLOOKUP(G2, A2:A4, XLOOKUP(H2, B1:E1, B2:E4))) This prevents errors when lookup cells are empty.

With SUM: =SUM(XLOOKUP(G2, A2:A4, XLOOKUP(H2:J2, B1:E1, B2:E4))) This can sum multiple columns returned by the inner XLOOKUP when you give it multiple lookup values.

With IFERROR: =IFERROR(XLOOKUP(G2, A2:A4, XLOOKUP(H2, B1:E1, B2:E4)), "Not found") Provides backward compatibility with older error-handling approaches.

Dynamic Arrays and Spill Ranges with Two Way XLOOKUP

One of XLOOKUP’s most powerful features is its ability to return multiple results that spill into adjacent cells. You can modify double XLOOKUP to return entire rows or columns:

To return an entire row: =XLOOKUP(G2, A2:A4, B2:E4) To return an entire column: =XLOOKUP(H2, B1:E1, B2:E4)

You can even return multiple intersections by providing arrays as lookup values. If G2:G4 contains multiple product names, XLOOKUP returns multiple results automatically, eliminating the need for copying formulas down.


Mastering double XLOOKUP opens up powerful data analysis capabilities in both Excel and Google Sheets. This two way lookup technique transforms complex matrix searches into simple, readable formulas that are easy to maintain and update. Whether you’re managing inventory, analyzing sales data, or building dynamic dashboards, double XLOOKUP is an essential tool in your spreadsheet arsenal. Best of all, the formula syntax works identically in both platforms, making it perfect for teams that use different tools or need to share workbooks across Excel and Google Sheets.

Shopping Cart
Scroll to Top