How can I use the IF Function with INDEX MATCH in Google Sheets?

The IF Function and INDEX MATCH are two powerful tools in Google Sheets that can be used together to perform conditional lookups. This means that you can use the IF Function to set a condition, and if that condition is met, the INDEX MATCH formula will search for a specific value in a given range and return a corresponding value from another column. This allows you to customize your lookup formula and make it more dynamic by including a condition. For example, you can use the IF Function to check if a certain value is present in a range, and if it is, use INDEX MATCH to retrieve a specific value associated with that value. This combination of functions can be helpful in various data analysis and management tasks.


You can use the following formula to combine the IF function with INDEX and MATCH in Google Sheets:

=IF(B1="Mavs",(INDEX(A7:D9,MATCH("Guard",A7:A9,0),3)),IF(B1="Pacers",(INDEX(A13:D15,MATCH("Guard",A13:A15,0),3))))

This particular formula first checks if the value in cell B1 is equal to “Mavs” – if it is then it looks for “Guard” in the range A7:A9 and returns the value in column 3 of the range A7:D9.

However, if the value in cell B1 is “Pacers” then it looks for “Guard” in the range A13:A15 and returns the value in column 3 of the range A13:D15.

The following example shows how to use this formula in practice.

Example: Use IF Function with INDEX MATCH in Google Sheets

Suppose we have two datasets that display various information about basketball players on two different teams:

Now suppose we would like to return the rebounds value for the Guard on either the Mavs or the Pacers team, depending on the team name that we type into cell B1.

To do so, we can type the following formula into cell B2:

=IF(B1="Mavs",(INDEX(A7:D9,MATCH("Guard",A7:A9,0),3)),IF(B1="Pacers",(INDEX(A13:D15,MATCH("Guard",A13:A15,0),3))))

The following screenshot shows how to use this formula in practice:

Google Sheets IF function with INDEX MATCH

Since the value in cell B1 is set to “Mavs” the formula returns the rebounds value for the Guard from the Mavs dataset, which turns out to be 2.

If we change the value in cell B1 to “Pacers” then the formula will automatically update to return the rebounds value for the Guard from the Pacers dataset instead:

The formula now returns a value of 4, which represents the rebounds value for the Guard from the Pacers dataset.

Additional Resources

The following tutorials explain how to perform other common tasks in Google Sheets:

x