Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Google Sheets QUERY Another Sheet: How-To Guide

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To query another sheet in Google Sheets, use the QUERY function with a SQL-like statement and a sheet reference that includes the sheet name, such as =QUERY(Sheet2!A1:C100, "SELECT A, B WHERE C > 10", 1). This pulls matching rows from the other tab into your current sheet without manual copying, and the results update when the source data changes. Before you start, make sure the source sheet has a clear header row and consistent data types in each column, because QUERY reads the first row as labels by default.

What You'll Need

  • A Google account with access to Google Sheets.
  • At least two sheets in the same spreadsheet file: one holding the source data (for example, Sheet2) and one where you want the query results.
  • A header row in the source data, with one column per field (for example, Name, Region, Sales).
  • Basic familiarity with column letters (A, B, C) and simple comparison operators such as =, >, <, and contains.

Step-by-Step

  1. Open the spreadsheet and identify the source tab. Note the exact tab name at the bottom of the screen (for example, SalesData). If the name contains spaces, you will need to wrap it in single quotes in the formula, like 'Sales Data'!A1:C100.
  2. Check the source data layout. Confirm that row 1 contains headers and that each column holds one type of data. QUERY treats a column with mixed numbers and text inconsistently, so clean up stray text in numeric columns before querying.
  3. Click the cell where the result should start. Choose an empty area on the destination sheet, typically cell A1. The QUERY output will spill into the cells below and to the right, so make sure those cells are empty.
  4. Type the QUERY formula. Start with =QUERY(, then add the data range including the sheet name, then a comma, then the query string in double quotes, then a comma and the number of header rows. For example: =QUERY(SalesData!A1:C100, "SELECT A, B, C", 1). This returns all three columns with the header row included.
  5. Press Enter. The matching rows appear in the destination sheet. If you see a #VALUE! or #NAME? error, check that the sheet name is spelled correctly and that the range uses the right column letters.
  6. Add a WHERE clause to filter rows. To show only rows where column C is greater than 100, change the query string to "SELECT A, B, C WHERE C > 100". Text comparisons need single quotes inside the double-quoted string, for example "SELECT A, B WHERE B = 'North'".
  7. Use ORDER BY to sort results. Append ORDER BY C DESC to sort by column C from highest to lowest. You can also use ORDER BY A ASC for alphabetical order.
  8. Limit the number of rows. Add LIMIT 10 to return only the first ten matching rows. This is useful for dashboards or summary views.
  9. Reference the header row correctly. The third argument of QUERY tells Sheets how many header rows the source range has. Use 1 if row 1 contains headers, or 0 if your data has no headers and you want all rows treated as data.
  10. Copy the formula down or across if needed. QUERY returns an array, so you usually place it in one cell only. If you need separate queries for different criteria, place each in its own cell with enough empty space below.

Menu labels and formula behaviour can differ slightly by Google Sheets version and region, but the QUERY syntax above is standard across the web app and mobile apps.

Common Mistakes

  • Forgetting to include the sheet name in the range. Writing A1:C100 queries the current sheet, not the other tab. Always use SheetName!A1:C100.
  • Using double quotes inside the query string. The query string itself is wrapped in double quotes, so text values inside it must use single quotes, for example WHERE B = 'North'.
  • Mismatched column letters. The SELECT clause uses column letters from the source range, not from the destination sheet. If your range starts at column B, then A in the query refers to the first column of that range.
  • Ignoring the header argument. If you omit the third argument, QUERY guesses the number of headers. Always set it explicitly to 1 or 0 to avoid dropped rows.
  • Leaving non-empty cells in the spill range. QUERY needs empty space below and to the right. Clear any existing data in those cells first.
  • Mixing data types in a column. A column containing both numbers and text can cause QUERY to treat everything as text, breaking numeric comparisons. Keep each column consistent.

Tips

  • Use named ranges to make formulas easier to read. Select the source range, then go to Data > Named ranges and give it a name like SalesData. Then write =QUERY(SalesData, "SELECT A, B", 1).
  • Combine QUERY with other functions. For example, wrap it in IFERROR to show a friendly message when no rows match: =IFERROR(QUERY(...), "No results").
  • Use SELECT * to return all columns without listing them individually, but be aware that this includes every column in the range.
  • Test your query on a small range first. Change the range to a few rows to confirm the logic before applying it to the full dataset.
  • Remember that QUERY is not case-sensitive for text comparisons in most cases, but exact matching may depend on the data.

Troubleshooting

If the formula returns an error, start with the simplest checks. First, confirm the source sheet name is spelled exactly as shown on the tab, including capitalisation and spaces. Second, verify that the range includes the columns you reference in the query. Third, check that the query string is enclosed in double quotes and that any text values inside use single quotes. If you see a #REF! error, the destination spill range may overlap existing data; clear the cells below and to the right. If you see #VALUE!, the query syntax may have a typo, such as a missing comma or an unrecognised keyword. If results are missing rows, check the header argument: set it to 0 if your data has no header row. If numbers are treated as text, clean the source column so it contains only numeric values. If the query works on desktop but not on mobile, note that the Google Sheets mobile app supports QUERY but the formula editing interface is more limited; try editing on a computer if you encounter issues.

Frequently Asked Questions

Can I query a sheet in a different spreadsheet file?

QUERY works within the same spreadsheet file. To pull data from another file, use IMPORTRANGE to bring the data into a sheet first, then query that sheet.

How do I query multiple sheets at once?

QUERY accepts a single range. To combine data from multiple sheets, use curly braces to create an array, such as {Sheet1!A1:C10; Sheet2!A1:C10}, and then wrap that in QUERY. The sheets must have the same column structure.

Why does my QUERY return only the header row?

This usually means no rows match the WHERE condition, or the header argument is set incorrectly. Check your criteria and try removing the WHERE clause to see if data appears.

Can I use cell references inside the query string?

Yes. Concatenate a cell reference into the query string, for example "SELECT A, B WHERE C > "&D1. Make sure the referenced cell contains a valid value for the comparison.

Does QUERY work with dates?

Yes, but dates in the query string must be formatted in a way Sheets recognises, typically as date '2024-01-01'. It is often easier to reference a date cell and concatenate it.

What is the maximum range size for QUERY?

QUERY can handle large ranges, but performance may slow with very large datasets. For best results, limit the range to the actual data area rather than entire columns.