6.2 C
London
Thursday, December 19, 2024
HomeSoftware TutorialsGoogle SheetsGoogle Sheets: How to Use IMPORTRANGE with Conditions

Google Sheets: How to Use IMPORTRANGE with Conditions

Related stories

Learn About Opening an Automobile Repair Shop in India

Starting a car repair shop is quite a good...

Unlocking the Power: Embracing the Benefits of Tax-Free Investing

  Unlocking the Power: Embracing the Benefits of Tax-Free Investing For...

Income Splitting in Canada for 2023

  Income Splitting in Canada for 2023 The federal government’s expanded...

Can I Deduct Home Office Expenses on my Tax Return 2023?

Can I Deduct Home Office Expenses on my Tax...

Canadian Tax – Personal Tax Deadline 2022

  Canadian Tax – Personal Tax Deadline 2022 Resources and Tools...

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:

Notice that only the Player and Points columns are returned where the team name is equal to Spurs.

Additional Resources

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

Google Sheets: How to Query From Another Sheet
Google Sheets Query: How to Use Multiple Criteria in Query
Google Sheets Query: How to Return Only Unique Rows

Subscribe

- Never miss a story with notifications

- Gain full access to our premium content

- Browse free from up to 5 devices at once

Latest stories