Google Sheets: Use IF Function with INDEX MATCH


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.

Note: To look up the rebounds value for a player in a different position, simply change “Guard” in the formula to a different position name.

Additional Resources

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

Google Sheets: How to Use SUM with INDEX MATCH
Google Sheets: How to Use INDEX MATCH with Multiple Criteria
Google Sheets: How to Use VLOOKUP to Sum Multiple Rows

Leave a Reply

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