How to use IMPORTRANGE with Conditions in Google Sheets?

Using IMPORTRANGE with conditions in Google Sheets allows you to copy data from a source sheet to a destination sheet, providing you with the ability to filter the data based on criteria. This is done by adding the AND, OR, or NOT operators to the query. This is useful for combining data from multiple sheets into one, or for copying only data that meets certain criteria.


You can use the following basic syntax to use the IMPORTRANGE function in Google Sheets with specific conditions:

=QUERY(IMPORTRANGE("URL","Sheet1!A1:G9"),"where Col2='Spurs'")

This returns only the data in the range A1:G9 from the tab named Sheet1 within the Google Sheets spreadsheet with a specific URL where the second column has a value of Spurs.

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

Example: Use IMPORTRANGE with Conditions

Suppose the data we’re interested in is located in a Google Sheets spreadsheet within a tab called stats at the following URL:

We can use the following syntax to return only the rows from this tab where the value in the second column is equal to Spurs:

=QUERY(IMPORTRANGE("1AdlE9V0aYMdrCmAGtvGXIEfo3szQ1tWRJ2HhJkUhg_4",
"stats!A1:C12"), "where Col2='Spurs'")

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

Google Sheets IMPORTRANGE with conditions

Notice that only the rows with the team name Spurs are returned.

You can also use the select statement to only return specific columns from the original spreadsheet.

For example, you can use the following syntax to return the values from only the Player and Points columns for the rows where the second column is equal to Spurs:

=QUERY(IMPORTRANGE("1AdlE9V0aYMdrCmAGtvGXIEfo3szQ1tWRJ2HhJkUhg_4",
"stats!A1:C12"), "select Col1, Col3 where Col2='Spurs'")

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

x