XLOOKUP With If Statement - Excel & Google Sheets (2024)

This tutorial will demonstrate how to combine the XLOOKUP and IF functions in Excel. If your version of Excel does not support XLOOKUP, read how to use VLOOKUP instead.

XLOOKUP With If Statement - Excel & Google Sheets (1)

XLOOKUP Multiple Lookup Criteria

There are a lot of ways to use the IF Function alongside the XLOOKUP Function, but first, let’s look at an example using the core element of the IF Function, the logical criteria.

One common example is performing a lookup with multiple criteria, and the most common solution to this is by concatenating the lookup criteria (e.g., F3&G3) and their corresponding column in the lookup data (e.g., B3:B7&C3:C7).

=XLOOKUP(F3&G3,B3:B7&C3:C7,D3:D7)

XLOOKUP With If Statement - Excel & Google Sheets (2)

The above method works fine most of the time, but it can lead to incorrect results for conditions that involve numbers.

A more foolproof method is by creating an array of Boolean values from logical criteria.

=XLOOKUP(1,(B3:B7=F3)*(C3:C7=G3),D3:D7)

XLOOKUP With If Statement - Excel & Google Sheets (3)

Let’s walk through this formula:

Logical Criteria

First, let’s apply the appropriate condition to their corresponding columns by using the logical operators (e.g., =,<,>).

Let’s start with the first criterion (e.g., Student ID).

=B3=$C$2

XLOOKUP With If Statement - Excel & Google Sheets (4)

Repeat the step for the other criteria (e.g., Subject).

=D3=$E$2

XLOOKUP With If Statement - Excel & Google Sheets (5)

Array AND

Next, we perform the array equivalent of the AND Function by multiplying the Boolean arrays where TRUE is 1 and FALSE is 0.

=C3*E3

XLOOKUP With If Statement - Excel & Google Sheets (6)

Note: The AND Function is an aggregate function (many inputs to one output). Therefore, it won’t work in our array scenario.

XLOOKUP Function

Next, we use the result of the Array AND as the new lookup array where we will lookup for 1 instead of the original lookup value.

=XLOOKUP(1,F3:F7,G3:G7)

XLOOKUP With If Statement - Excel & Google Sheets (7)

Combining all formulas above results to our original formula:

=XLOOKUP(1,(B3:B7=F3)*(C3:C7=G3),D3:D7)

XLOOKUP Error-Handling with IF

Sometimes we need to check if the result of an XLOOKUP Function results in an error. A great way of doing this is by using the IF Function, which is also the best way of notifying us about the cause of the error.

XLOOKUP IF with ISNA

Let’s first check if the XLOOKUP failed to find a match using the IF with ISNA Formula.

=IF(ISNA(XLOOKUP(E3,B3:B7,C3:C7)),"Product not found!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (8)

Let’s walk through the above formula:

ISNA Function

First, let’s check for the #N/A Error, which basically means no match was found, using the ISNA Function.

=ISNA(XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (9)

IF Function

Next, let’s use the IF Function to check the result of the ISNA Function and return a message (e.g., “Product not found!”) if the result is TRUE. Otherwise, if the result is false, we’ll proceed with the calculation.

=IF(G3,"Product not found!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (10)

Combining all formulas results to our original formula:

=IF(ISNA(XLOOKUP(E3,B3:B7,C3:C7)),"Product not found!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP IF with ISBLANK

Another thing to check is if the result of XLOOKUP is blank. There are cases where blank means there’s no input yet, and therefore, we need to distinguish it from zero.

We’ll just replace the ISNA with ISBLANK to check for blank.

=IF(ISBLANK(XLOOKUP(E3,B3:B7,C3:C7)),"No data!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (11)

Let’s walk through the above formula:

ISBLANK Function

First, let’s check for blank using the ISBLANK Function.

=ISBLANK(XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (12)

IF Function

Just like with the previous scenario, we then input the result of the ISBLANK Function to the IF Function and return a message (e.g., “No Data!”) if TRUE or proceed with the calculation if FALSE.

=IF(G3,"No data!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (13)

Combining all formulas results to our original formula:

=IF(ISBLANK(XLOOKUP(E3,B3:B7,C3:C7)),"No data!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (14)

XLOOKUP IF with ISTEXT

Another thing to avoid in calculations is accidental text input. In this case, we’ll use the IF with ISTEXT Formula to check for a text value.

=IF(ISTEXT(XLOOKUP(E3,B3:B7,C3:C7)),"Invalid input!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (15)

ISTEXT Function

First, we check if the output of the XLOOKUP Function is a text.

=ISTEXT(XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (16)

IF Function

Next, we check the result using the IF Function and return the corresponding message (e.g., “Invalid input!”) if TRUE or proceed to the calculation if FALSE.

=IF(G3,"Invalid input!",F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (17)

XLOOKUP with IFS

The final error-handling formula would be the combination of the previous IF Formulas, and we can do this by nesting them.

=IF(ISNA(XLOOKUP(E3,B3:B7,C3:C7)),"Product not found!", IF(ISBLANK(XLOOKUP(E3,B3:B7,C3:C7)),"No data!", IF(ISTEXT(XLOOKUP(E3,B3:B7,C3:C7)),"Invalid input!",F3/XLOOKUP(E3,B3:B7,C3:C7)) ) )

XLOOKUP With If Statement - Excel & Google Sheets (18)

As we notice above, the Nested IF Formula becomes more complicated as we add more conditions. A better way to approach this is by using the IFS Function.

=IFS(ISNA(XLOOKUP(E3,B3:B7,C3:C7)),"Product not found!",ISBLANK(XLOOKUP(E3,B3:B7,C3:C7)),"No data!",ISTEXT(XLOOKUP(E3,B3:B7,C3:C7)),"Invalid input!",TRUE,F3/XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (19)

Note: The IFS Function can evaluate multiple sets of logical criteria. It starts from the first condition moving on to the next until it finds the first TRUE condition and returns the corresponding return value to it.

Let’s walk through the formula above:

ISNA

We start with our first condition, which is the ISNA Function. If ISNA is TRUE, we return its corresponding value (e.g., “Product not found!”). Otherwise, we proceed to check the next condition.

=ISNA(XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (20)

ISBLANK and ISTEXT

Since the first condition is FALSE in this scenario, we check the succeeding conditions until we find the first TRUE and return the corresponding value for the TRUE condition.

=ISBLANK(XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (21)

=ISTEXT(XLOOKUP(E3,B3:B7,C3:C7))

XLOOKUP With If Statement - Excel & Google Sheets (22)

Default Value

We can set a default value by setting the last condition as TRUE in case all the conditions are FALSE, which in our error-handling scenario, means that we can now proceed to the calculation without errors.

XLOOKUP With If Statement - Excel & Google Sheets (23)

Combining all formulas above results to our original formula:

=IFS(ISNA(XLOOKUP(E3,B3:B7,C3:C7)),"Product not found!",ISBLANK(XLOOKUP(E3,B3:B7,C3:C7)),"No data!",ISTEXT(XLOOKUP(E3,B3:B7,C3:C7)),"Invalid input!",TRUE,F3/XLOOKUP(E3,B3:B7,C3:C7))
XLOOKUP With If Statement - Excel & Google Sheets (2024)

FAQs

Can you use xlookup in an if statement? ›

You can use the XLOOKUP function in Excel to look up some value in a column and return the corresponding value in a different column.

Does Xlookup work with Google Sheets? ›

XLOOKUP is a function in Google Sheets that searches for a value in a specified range and returns a corresponding value in another specified range.

Can you use xlookup with two conditions? ›

You can use as many conditions as you need. Just make sure that all the lookup arrays are the same size. Dynamic arrays. You can use XLOOKUP with dynamic arrays, which means that you can spill the results to multiple cells without using old-fashioned Ctrl + Shift + Enter array formulas.

How do you use Xlookup for multiple results? ›

If your lookup array contains multiple occurrences of the lookup value and you aim to return all matches, XLOOKUP cannot do that. In this case, you can use the FILTER function or the combination of INDEX, SMALL and ROW functions as demonstrated in this tutorial: How to Vlookup multiple matches in Excel.

Can you do an if statement in a VLOOKUP Google Sheets? ›

Using VLOOKUP with IF statements in Google Sheets allows you to perform advanced comparisons and return specific values based on various conditions. This combination can handle scenarios where you need to check if a value meets certain criteria and then return corresponding data from a table.

Can you combine VLOOKUP and if statement in Excel? ›

Did you know that you can use Excel IF statements along with VLOOKUPs? For example, if you wanted to enter a value from a table into a cell, based on what was in another cell, you could start with an IF statement and then enter the VLOOKUP in the “value if true” part of the IF statement.

What is the Google equivalent of Xlookup? ›

The return_array is the range that contains the value you would like to return, C5:C15.
  1. XLOOKUP in Excel.
  2. Use INDEX/MATCH in place of XLOOKUP in Google Sheets.
  3. Use VLOOKUP in place of XLOOKUP in Google Sheets.
  4. Use QUERY in place of XLOOKUP in Google Sheets.
  5. Use FILTER in place of XLOOKUP in Google Sheets.

Is Google Sheets fully compatible with Excel? ›

You can import data from an Excel file to a new (or existing) Sheets file. Your Excel file won't be changed, even as you change the Sheets file. In Sheets, create a new or open an existing spreadsheet. Import.

Is xlookup better than VLOOKUP? ›

Making the Choice between VLOOKUP vs XLOOKUP

XLOOKUP is more flexible and powerful, but it's only available in Excel 2021 (and above) and Microsoft 365. While it has its limitations, VLOOKUP is still useful, especially if you're working with older Excel versions (Excel 2019 and below) or need something simpler.

What are the drawbacks of Xlookup in Excel? ›

Some of the drawbacks of XLOOKUP are:
  • It is not compatible with older versions of Excel 2019 and lower.
  • It may not be as flexible as INDEX MATCH for some scenarios, such as returning values from non-contiguous columns.
  • It may not work well with large data sets or volatile formulas.
Jan 24, 2024

What is the limitation of Xlookup? ›

Does Xlookup have a limit? The Xlookup function doesn't have a limit. This means you can use all 1,048,576 rows and 16,384 columns of a workbook. You may benefit from using Xlookup for large files, such as worksheets with company-wide information on all employees and upper management.

Can Xlookup return multiple values in Google Sheets? ›

XLOOKUP can return not just one but multiple adjacent cells as a result of a single function.

How to apply xlookup in Google Sheets? ›

XLOOKUP Examples in Google Sheets
  1. In an empty cell, type the XLOOKUP formula and add the search key as the first parameter. ...
  2. For the second parameter, select the row where you want to find the search key. ...
  3. For the third parameter, specify the row from which you want the result.
Mar 13, 2024

How to do a lookup based on two conditions? ›

One easy way of performing a multiple criteria lookup is by using XLOOKUP with the "&" operator that concatenates all the criteria into one lookup value and their corresponding lookup columns into one lookup array. This approach is more efficient than using VLOOKUP because you don't need the helper column.

Is Xlookup more efficient than index match? ›

Conclusion: INDEX / MATCH is still the best and most robust formula to reference information on another Excel tab or workbook. XLOOKUP comes close (nice try Microsoft), but it still falls short when it comes to adapting to changes to the source table.

Can you nest a VLOOKUP in an if statement? ›

Use the IF and VLOOKUP Nested Formula to Lookup Based on Two Values. Matching Lookup Returns with Another Cell. Use Nested Function with IF & VLOOKUP to Lookup Values from a Shorter List. Use of IF and VLOOKUP Nested Function to Perform Different Calculations.

How do I do a VLOOKUP with an if condition? ›

Here's how the formula works:
  1. (VLOOKUP(B9, $B$9:$D$14, 2, FALSE) looks up the product in B9 from column A and returns the price from column C.
  2. The IF() statement checked if the price is greater than $50 .
  3. If true, our code returns the stock quantity: VLOOKUP(B9,$B$9:$D$14, 3, FALSE) .

Can you use Xlookup in conditional formatting? ›

Re: xlookup with format

Excel's lookup functions can only search for a cell's value, not its formatting. If the lookup range has been colored using conditional formatting, you should use the conditions of the conditional formatting rules, Otherwise, you'd need VBA code.

Can you put a boolean in an if statement? ›

The simplest if-statement has two parts – a boolean "test" within parentheses ( ) followed by "body" block of statements within curly braces { }. The test can be any expression that evaluates to a boolean value – true or false – value (boolean expressions are detailed below).

Top Articles
Wheel Lug Torque Chart
I Went in Search of the Best Supportive and Cooling Mattress—Here's the Winner
Frases para un bendecido domingo: llena tu día con palabras de gratitud y esperanza - Blogfrases
855-392-7812
Paris 2024: Kellie Harrington has 'no more mountains' as double Olympic champion retires
Evil Dead Rise Showtimes Near Massena Movieplex
Kansas Craigslist Free Stuff
Noaa Swell Forecast
Volstate Portal
Saw X | Rotten Tomatoes
Morocco Forum Tripadvisor
People Portal Loma Linda
Hell's Kitchen Valley Center Photos Menu
25Cc To Tbsp
Bj Alex Mangabuddy
Der Megatrend Urbanisierung
Lazarillo De Tormes Summary and Study Guide | SuperSummary
Days Until Oct 8
Breckie Hill Mega Link
Sussur Bloom locations and uses in Baldur's Gate 3
Babbychula
All Obituaries | Gateway-Forest Lawn Funeral Home | Lake City FL funeral home and cremation Lake City FL funeral home and cremation
Greyson Alexander Thorn
Macu Heloc Rate
Avatar: The Way Of Water Showtimes Near Maya Pittsburg Cinemas
897 W Valley Blvd
Ups Drop Off Newton Ks
Jt Closeout World Rushville Indiana
The Ultimate Guide to Obtaining Bark in Conan Exiles: Tips and Tricks for the Best Results
Average weekly earnings in Great Britain
Baddies Only .Tv
Gr86 Forums
Ixlggusd
Ultra Clear Epoxy Instructions
Bozjan Platinum Coins
Kips Sunshine Kwik Lube
Skyrim:Elder Knowledge - The Unofficial Elder Scrolls Pages (UESP)
Giantess Feet Deviantart
Kazwire
Kelly Ripa Necklace 2022
Nsav Investorshub
Noaa Marine Weather Forecast By Zone
Metro Pcs Forest City Iowa
Conan Exiles Armor Flexibility Kit
Wilson Tire And Auto Service Gambrills Photos
Ehc Workspace Login
Fluffy Jacket Walmart
Rise Meadville Reviews
The Pretty Kitty Tanglewood
Dineren en overnachten in Boutique Hotel The Church in Arnhem - Priya Loves Food & Travel
Phunextra
Convert Celsius to Kelvin
Latest Posts
Article information

Author: Lidia Grady

Last Updated:

Views: 6435

Rating: 4.4 / 5 (45 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Lidia Grady

Birthday: 1992-01-22

Address: Suite 493 356 Dale Fall, New Wanda, RI 52485

Phone: +29914464387516

Job: Customer Engineer

Hobby: Cryptography, Writing, Dowsing, Stand-up comedy, Calligraphy, Web surfing, Ghost hunting

Introduction: My name is Lidia Grady, I am a thankful, fine, glamorous, lucky, lively, pleasant, shiny person who loves writing and wants to share my knowledge and understanding with you.