Formula guide · Google Sheets · Updated May 13, 2026

QUERY with IMPORTRANGE

Combine QUERY and IMPORTRANGE to filter imported Google Sheets data.

Quick Answer

When QUERY wraps IMPORTRANGE, use Col1, Col2, Col3 style references instead of A, B, C.

Copyable Formula

=QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/example","Orders!A:D"),"select Col1, Col4 where Col3 = 'Paid'",1)

Syntax

=QUERY(IMPORTRANGE("url","Sheet1!A:D"),"select Col1, Col4 where Col3 = 'Paid'",1)

Google Sheets

Worked Example

PartRule
IMPORTRANGEbrings in source data
QUERYfilters imported rows
Col referencesuse Col1, Col2, Col3

Result: Imports the source range and returns only selected paid rows.

Steps

  • Test IMPORTRANGE by itself first and allow access.
  • Wrap it in QUERY.
  • Use Col1 style references inside the query string.
  • Import only the columns needed for the report.

Common Mistakes

  • Using A, B, C column letters with an IMPORTRANGE array.
  • Debugging QUERY before confirming IMPORTRANGE has permission.
  • Importing a huge source range when only a few columns are needed.

Excel vs Google Sheets Notes

This page is focused on Google Sheets. Excel may require a different function, pivot table, or Power Query workflow.

Editorial check: This guide was last updated May 13, 2026. Formula behavior can vary by Excel version, Google Sheets rollout, and spreadsheet locale.

FAQ