Templates, guides & honest tool reviews for small business

Sunday, November 29, 2026

IMPORTRANGE in Google Sheets with Conditions: QUERY and FILTER Examples

IMPORTRANGE in Google Sheets with conditions using QUERY and FILTER
Illustration: IMPORTRANGE in Google Sheets with conditions

To use IMPORTRANGE in Google Sheets with conditions, you wrap IMPORTRANGE inside QUERY or FILTER. IMPORTRANGE alone pulls a whole range from another spreadsheet. QUERY and FILTER then keep only the rows that meet your rule, such as "amount over 100" or "status is Open". This guide shows both formulas with made-up data, and explains the access message and the errors you may see.

IMPORTRANGE in Google Sheets: allow access to fix the REF error
First use of a new file asks for access (illustration).

What IMPORTRANGE does on its own

IMPORTRANGE takes two arguments: the URL (or ID) of the other spreadsheet, and the range to copy, written as text. For example:

=IMPORTRANGE("https://docs.google.com/spreadsheets/d/YOUR_SHEET_ID", "Orders!A1:D100")

The first time you use it with a new file, Google Sheets shows #REF! and a button to allow access. Click Allow access once and the data appears. If you are new to the function, start with our guide to how to use IMPORTRANGE in Google Sheets.

IMPORTRANGE with QUERY: select where Col4 is greater than 100
Imported columns are named Col1, Col2 and so on (illustration).

IMPORTRANGE with a condition using QUERY

Say the other file has a sheet named Orders with Date in column A, Customer in B, Status in C and Amount in D. To import only rows where the amount is over 100:

=QUERY(IMPORTRANGE("YOUR_URL","Orders!A1:D100"), "select * where Col4 > 100", 1)

Inside QUERY, imported columns are called Col1, Col2, Col3 and so on, not A, B, C. The last number, 1, tells QUERY that the first row is a header.

Text conditions and several conditions

Text values go in single quotes. To get only rows with status Open:

=QUERY(IMPORTRANGE("YOUR_URL","Orders!A1:D100"), "select * where Col3 = 'Open'", 1)

Join rules with and or or:

=QUERY(IMPORTRANGE("YOUR_URL","Orders!A1:D100"), "select Col2, Col4 where Col3 = 'Open' and Col4 > 100", 1)

This returns only the Customer and Amount columns for open orders over 100.

IMPORTRANGE with FILTER and a condition stored in a cell
Two ways to add a condition (illustration).

IMPORTRANGE with a condition using FILTER

FILTER is another option. It works well when you need one rule:

=FILTER(IMPORTRANGE("YOUR_URL","Orders!A2:D100"), INDEX(IMPORTRANGE("YOUR_URL","Orders!A2:D100"),,4) > 100)

This calls IMPORTRANGE twice, which makes it long. For most people QUERY is easier to read.

Use a cell for the condition

You can type the limit in a cell, such as F1, and join it into the query text:

=QUERY(IMPORTRANGE("YOUR_URL","Orders!A1:D100"), "select * where Col4 > "&F1, 1)

Change F1 and the result updates. For text, wrap the cell in single quotes inside the text: "select * where Col3 = '"&F1&"'".

IMPORTRANGE QUERY errors: REF, VALUE and parse errors with fixes
Common errors and fixes (illustration).

Fix common errors

  • #REF! "You need to connect these sheets". Click Allow access.
  • #VALUE! or "Unable to parse query". Check the quotes. Use Col1 style names, not letters.
  • Imported result is empty. The condition may match no rows, or the range name has a typo.
  • Array result was not expanded. The cells where the result should land must be empty.

IMPORTRANGE with conditions: common questions

Can I use column letters inside QUERY with IMPORTRANGE?

No. Use Col1, Col2 and so on for the imported range.

Does the other spreadsheet have to be shared?

You need at least view access to it. You also have to allow the connection the first time.

How do I count the imported rows that match?

Use a QUERY with select count(Col1) in place of select *. See also SUMIF with multiple criteria.

Related guides on Sheets AI Hub

Build a report on top of imported data with our Google Sheets dashboard guide, and clean it with remove duplicates.

العربية