2-Way XLOOKUP in Excel: Beginner to Advanced

Bottom Line: Master the 2-way XLOOKUP to streamline your Excel skills—covering everything from basic setup to advanced error handling, making data retrieval more efficient than ever.

Watch the Video

Watch on YouTube & Subscribe to our Channel

Download the Excel File

You can access the same file you see in the video by downloading it below.

Learning Excel’s lookup formulas can be a game-changer for streamlining your data processes. Here, we’ll explore 2-way XLOOKUP to tackle double lookups with confidence, retrieving data based on both rows and columns.

2-Way XLOOKUP for Rows and Column in Table in Excel

Basic 2-Way XLOOKUP Setup

  1. Starting with Rows: Using the data set provided in the file above, begin by typing =XLOOKUP( and setting your team (row) as the lookup value. Select your row range, and press F4 to lock the range.
  2. Adding Columns: Next, nest another XLOOKUP to handle the plan (column) lookup by selecting the plan header row and applying F4 to anchor it.
  3. Final Return Array: For the return array, select the entire range of values in the source data to allow dynamic row/column results, providing an efficient way to cross-reference values.

Your formula should look something like this:

=XLOOKUP(J6,$B$6:$B$10,XLOOKUP(K6,$C$5:$F$5,$C$6:$F$10))

Basic double xlookup formula

Advanced Error Handling with 2-Way XLOOKUP

Handling errors effectively in a 2-way XLOOKUP setup requires managing both row and column lookups separately, allowing you to see exactly which part of the lookup is causing an issue. Here’s how you can achieve this with two different approaches:

  1. Error Handling for Row Lookup (Team Not Found):
    If the team name you’re trying to look up doesn’t exist in the data, Excel would return an error. By adding if_not_found to the first XLOOKUP (the row lookup), you can set up a custom error message that clearly indicates the issue is with the row.
    • For example, append , "Team NF" to the end of the row lookup within the XLOOKUP function. Here, “Team NF” stands for “Team Not Found” and will appear any time the lookup value in the team row isn’t present.
  2. Error Handling for Column Lookup (Plan Not Found):
    Unlike the row lookup, if the plan you’re referencing isn’t available, the entire XLOOKUP will still attempt to complete. Since this component doesn’t use the if_not_found argument, wrap this part of the formula in an IFERROR statement. This way, if the XLOOKUP can’t find the specified column header, it will display a custom error for the plan.
    • For example, IFERROR(XLOOKUP(...), "Plan NF") will ensure the formula returns “Plan NF” for a missing plan, giving you separate, specific messages for missing rows or columns.

This handling provides clear error messages that show where the data retrieval issue lies, making it easier to diagnose and resolve mismatches in your data.

Advanced double xlookup formula

Working with Excel Tables

Switching your data to Excel tables can automate formula management. Instead of fixed ranges, reference the header row and entire table to keep formulas dynamic as the table grows.

Using Excel Tables, our formula would look something like this:

=XLOOKUP([@Team],tblRate[Team],XLOOKUP([@Plan],tblRate[#Headers],tblRate))

2-Way XLOOKUP with Excel Tables
Click to enlarge

For more information on how to get started using Excel Tables, check out this tutorial: Excel Tables Tutorial Video – Beginners Guide for Windows & Mac


Using XLOOKUP for Range Lookups (Closest Match)

For lookups where you need to find a value within a range rather than an exact match, XLOOKUP’s Closest Match option offers a solution. This is particularly useful in tier-based data, where the exact lookup value may not exist in the dataset but should fall within a specific range.

Double XLOOKUP for ranges.
Click to enlarge

In this scenario, set up your data to have tier minimums in a separate row to act as lookup references. For example, if you’re working with sales ranges, the tier minimums row might include values like 0, 20,000, 50,000, and so on.

  • Step-by-Step for Closest Match:
    • Step 1: Begin with your primary XLOOKUP for the row (e.g., team) and select the tier minimums row as the array for the column XLOOKUP.
    • Step 2: Instead of an exact match, use match_mode = -1 for Next Smaller Item. This tells Excel to return the closest, smaller tier when the exact match isn’t available. For example, if you’re looking up a sales value of 98,000, the formula will find the tier below it (50,000) if an exact match doesn’t exist.

This ensures the lookup references the appropriate range and calculates the corresponding value accurately. It’s especially helpful when ranges are large or data is not in strict order, as XLOOKUP can manage unordered lists and still retrieve the correct range.

Here's how the formula looks for our example:

=XLOOKUP(J7,$B$7:$B$11,XLOOKUP(K7,$C$4:$F$4,$C$7:$F$11,,-1))


Comparing XLOOKUP with INDEX MATCH

While both 2-way XLOOKUP and INDEX MATCH offer similar results, XLOOKUP has:

  • Fewer functions, making it simpler to write and troubleshoot.
  • Superior error-handling capabilities, allowing specific error messages for rows and columns separately.
XLOOKUP VS. INDEX MATCH

If you'd like to learn more about how INDEX MATCH works, watch this video: How to Use Index Match Instead of Vlookup


Practice Challenge

Finally, test your skills with this 2-way XLOOKUP practice challenge. Download the Excel file [EMBED] and try writing formulas to complete each example.

Practice challenge for 2-way XLOOKUP

Conclusion

Using a 2-way XLOOKUP formula enables you to look up complex data efficiently. This tutorial covered basics to advanced applications, equipping you to handle real-world scenarios in Excel. Leave a comment and let us know how you’re applying this technique!

Black Friday Offer – Modern Formulas

Ready to master Excel's most powerful new features? For a limited time, our updated Modern Formula course will be available at a special Black Friday price.

You'll learn how to harness game-changing innovations like XLOOKUP and Dynamic Array Formulas, helping you solve complex problems with elegant solutions that automatically adapt to your data. Whether you're tired of maintaining complex nested formulas or want to stay ahead of Excel's rapid evolution, this comprehensive 31-lesson course will transform how you work.

Click here to join the waitlist and get notified of our Black Friday Sale– and if you're already an Elevate Excel member, you can start learning immediately at no additional cost!

2 comments

Your email address will not be published. Required fields are marked *

  • Hi Jon,

    Thanks for your interesting video (as usual).

    For the first exercise, I used a lot a special technique in the past combining the INDIRECT() function and the INTERSECTION operator (the empty space), that I’d like to share in case it triggers some interest.

    First, I create some ranges according to the Commissiong Rates table.
    For this, I just select the rangeB5:F10 and press CTRL-SHIFT-F3. I create the range names based on both top row and left column. This generates (vertically) range names “Bronze”, “Silver”, “Gold” and “Platinum” and (horizontally) range names for “Team_A”, “Team_B”, “Team_C”, “Team_D”.

    Then I can use the intersection operator in cell L6 (and below) using this formula : =INDIRECT(J6) INDIRECT(K6)
    The formula will return the value that intersect the Team (J6) and the Plan (K6).

    I don’t know how good it is, but I think it is not a widely spread approach. what do you think of it ?

    Yves

    PS: In this very example, I had to add a underscore in the Team names of the column J, because Excel replaced the empty space from column B into an underscore when creating the range names.

  • Thanks, I did not know “=FORMULATEXT(J12)” till now, I simply added a quote ‘ before the formula to indicate it’s a text, it’s quite faster…

Generic filters
Exact matches only

Excel Shortcuts List

keyboard shortcuts list banner

Learn over 270 Excel keyboard & mouse shortcuts for Windows & Mac.

Excel Shortcuts List

Join Our Weekly Newsletter

The Excel Pro Tips Newsletter is packed with tips & techniques to help you master Excel.

Join Our Free Newsletter