QUERY #N/A: Query Completed With an Empty Output

When Google Sheets QUERY returns #N/A or only a header row, the query ran but matched no rows. Check case, text numbers, spaces, and date criteria.

本文目錄

The Harbor roster for 16 November is supposed to list every student at that site. If the QUERY compares Week to a concatenated DATE value, the cell shows only the header row: Student, Class, and Hours. There is no #N/A, so IFNA does not help. The query ran. It just did not see those dates the way they were stored.

Here is the signup sheet behind the report. Enter these values in A1:E9 on a blank Google Sheet:

Week網站StudentClassHours
2026-11-09HarborIris ChenRobotics2
2026-11-09RidgeFelix ParkArt3
2026-11-09HarborTessa ReedCoding2
2026-11-09RidgeJulian MossRobotics2
2026-11-16HarborPriya ShahArt3
2026-11-16HarborEllis GrantRobotics2
2026-11-16RidgeRowan BellCoding3
2026-11-16HarborCelia BrooksArt2

Three details in that table matter later, and they are not marked inside the cells. B6 displays Harbor, which we will also test in lowercase. B7 is Harbor followed by one trailing space; LEN(B7) is 7, and CODE(RIGHT(B7,1)) is 32. E8 displays 3 but is stored as text: type a leading apostrophe ('3) so the cell still shows 3. Enter the Week values as real dates, not text and not plain serial numbers, and format them as yyyy-mm-dd.

For the current week’s Harbor list, this formula returned Priya Shah with Art and 3 hours, and Celia Brooks with Art and 2 hours:

=QUERY(A1:E9,"select C, D, E where B = 'Harbor' and A = date '2026-11-16'",1)

Ellis Grant is in that week at Harbor, but B7 has the trailing space, so he is left out. The two matching hours add to 5.

Google Sheets with G1 selected, showing =QUERY(A1:E9,"select C, D, E where B = 'Harbor' and A = date '2026-11-16'",1) in the formula bar. The result in G1:I3 lists Student, Class, Hours, then Priya Shah, Art, 3 and Celia Brooks, Art, 2. Ellis Grant's Harbor row for 2026-11-16 is in the source table but not in the result.
Screenshot: Google Sheets, Nov 2026

If the cell is #N/A, or if you only get a header row and no students, work through the criteria and the source cells before wrapping the formula.

No signups for that site and week

The coordinator points the report at Ridge for the week of 23 November. Nobody has signed up for that combination. With the third argument set to 0, this formula returns #N/A and the message “Query completed with an empty output”:

=QUERY(A1:E9,"select C, D, E where B = 'Ridge' and A = date '2026-11-23'",0)

That is a successful empty search, not a formula that needs repairing. To confirm there are no matching source rows, count them directly:

=COUNTIFS(A2:A9,DATE(2026,11,23),B2:B9,"Ridge")

That returns 0.

If you keep the third argument at 1, the same criteria do not show #N/A. The formula returns only the header row: Student, Class, and Hours. IFNA does not replace that header, because there is no #N/A to catch.

A one-cell fallback is useful for the #N/A case:

=IFNA(QUERY(A1:E9,"select C, D, E where B = 'Ridge' and A = date '2026-11-23'",0),"No signups")

The cell displays No signups. COUNTA of that cell is 1. SUM of that cell is 0, because Sheets ignores the text. I wouldn’t use that display cell as an attendance count or a total of hours, and I wouldn’t add the wrapper until the criterion has been checked. A typo in the site name produces the same No signups message as a quiet week.

Count and total from the source instead. For the original Harbor week, before the trailing space is removed:

=COUNTIFS(A2:A9,DATE(2026,11,16),B2:B9,"Harbor")

returns 2, because Ellis Grant’s site has the extra space.

=SUMIFS(E2:E9,A2:A9,DATE(2026,11,16),B2:B9,"Harbor")

returns 5.

Lowercase harbor does not match Harbor

QUERY text comparisons are case-sensitive. If the criterion is harbor and the source rows contain Harbor, no row matches. With the third argument set to 0, this formula returns #N/A and “Query completed with an empty output”:

=QUERY(A1:E9,"select C where B = 'harbor'",0)

With the third argument set to 1, the same criterion returns only the header Student.

Correct the capitalization:

=QUERY(A1:E9,"select C where B = 'Harbor'",1)

This returns Iris Chen, Tessa Reed, Priya Shah, and Celia Brooks. Ellis Grant is still excluded by the trailing space.

If site names arrive with mixed capitalization, lowercase the comparison. This still does not fix whitespace:

=QUERY({ARRAYFORMULA(LOWER(B2:B9)),C2:C9},"select Col2 where Col1 = 'harbor'",0)

It returns the same four students. Ellis Grant is still missing, because LOWER of Harbor is harbor with the trailing space intact.

Hours that look like 3 but are text

The Hours column looks numeric throughout. E8, Rowan Bell’s three-hour Coding signup, is text. ISNUMBER(E8) returns FALSE.

A query that asks for numeric hours equal to 3 therefore omits that row:

=QUERY(A1:E9,"select C where E = 3",1)

This returns Felix Park and Priya Shah, but not Rowan Bell.

Google Sheets with G1 selected, showing =QUERY(A1:E9,"select C where E = 3",1) in the formula bar. Under Student the result lists only Felix Park and Priya Shah. Rowan Bell's Hours cell E8 also shows 3, but it sits left-aligned while the other hours are right-aligned, and Rowan Bell is not in the result.
Screenshot: Google Sheets, Nov 2026

Quoting the number turns the criterion into a text literal:

=QUERY(A1:E9,"select C where E = '3'",1)

That is not a fix for a mostly numeric Hours column. In this sheet it returned only the Student header. It did not bring back the minority text value.

Replace the text entry in E8 with numeric 3, without the leading apostrophe. Then the numeric query returns Felix Park, Priya Shah, and Rowan Bell. A source-level check is:

=COUNTIF(ARRAYFORMULA(ISNUMBER(E2:E9)),FALSE)

This returns 1 before the correction and 0 afterward. For a larger import, use the methods in Convert Text to Numbers rather than retyping hundreds of cells.

Date criteria depend on whether Week is a date or a serial

The Week cells in the sample are real dates. ISNUMBER(A6) is TRUE, and TEXT(A6,"yyyy-mm-dd") returns 2026-11-16. Those two checks are not enough on their own, because a plain date serial can look the same. In this file, QUERY treated the formatted date column as a date. The documented date literal matched four students on 16 November:

=QUERY(A1:E9,"select C where A = date '2026-11-16'",1)

It returned Priya Shah, Ellis Grant, Rowan Bell, and Celia Brooks. The same four names came back from year(A)=2026 and month(A)=11 and day(A)=16.

A concatenated DATE value is a serial number written into the query string, and it did not match those real dates:

=QUERY(A1:E9,"select C, D, E where B = 'Harbor' and A = "&DATE(2026,11,16),1)

This returned only the header row. A = 46342 did the same. QUERY(A1:A9,"select avg(A)",1) returned #VALUE!, with the message “Unable to parse query string for Function QUERY parameter 2: AVG_SUM_ONLY_NUMERIC.”

COUNTIFS 與 FILTER still accept DATE(2026,11,16) against the same real dates. FILTER of the student names for Harbor on that week returned Priya Shah and Celia Brooks.

If Week is stored as plain serial numbers instead, the results flip. In a copy of the table that used 46335 and 46342 with no date format, date '2026-11-16' returned only the Student header, avg(A) returned 46338.5, and year(A) returned #VALUE!, with the message that year cannot run on a column that is not a Date or a DateTime column. The concatenated DATE(2026,11,16) form then matched the four 16 November rows. If COUNTIFS finds rows and a date-literal QUERY does not, check whether Week is a real date or only a number that formats like one. Re-enter the values as dates, or use the concatenated form only when QUERY is treating the column as numbers.

A literal that is simply the wrong day also returns empty, and that is easy to mix up with the storage mismatch above. With the third argument set to 0, this formula returned #N/A and “Query completed with an empty output”:

=QUERY(A1:E9,"select C where A = date '2026-11-17'",0)

COUNTIFS on 17 November returns 0, which confirms the week is genuinely absent. If COUNTIFS finds rows and the QUERY does not, the date criterion or the way Week is stored is the problem, not the signups.

A cell that only looks like a date is a third case. In a copy of the table, Priya Shah’s week was the text 2026-11-16 rather than a date value. ISNUMBER was FALSE. The date-literal query returned Ellis Grant, Rowan Bell, and Celia Brooks, and skipped Priya. COUNTIFS on that one text cell still returned 1, so a source count can include a text date that QUERY skipped. Check ISNUMBER on the Week cells and convert text dates rather than trusting either result. Dates stored as text covers the cleanup.

Mixed types drop a row that you can see

When a column contains mixed types, QUERY uses the majority type and treats minority values as null. That is why Rowan Bell’s row is missing from where E = 3 while E8 still displays 3. Seven Hours entries are numeric; one is text.

The gap is easier to miss when the report targets that student:

=QUERY(A1:E9,"select C where C = 'Rowan Bell' and E = 3",1)

This returns only the Student header, even though the row is visible. After E8 is replaced with numeric 3, the same query returns Rowan Bell. I’d fix the imported column once rather than maintain different QUERY expressions for numeric and text hours.

Trailing space in the site name

Ellis Grant’s row is in the current week, but B7 contains Harbor rather than Harbor. LEN(B7) returns 7; Harbor has 6 characters.

A query for that student and the clean site name misses the row. With the third argument set to 0, this returns #N/A and “Query completed with an empty output”:

=QUERY(A1:E9,"select C where B = 'Harbor' and C = 'Ellis Grant'",0)

If you can edit the source, delete the trailing space in B7. Then the same query returns Ellis Grant. If the imported values have to stay as they are, trim the site column in the QUERY input:

=QUERY({A2:A9,ARRAYFORMULA(TRIM(B2:B9)),C2:E9},"select Col3 where Col2 = 'Harbor' and Col3 = 'Ellis Grant'",0)

This returns Ellis Grant.

The extra space can also sit in the criterion cell. If G2 holds the selected site, trim it when you build the string:

=QUERY(A1:E9,"select C where B = '"&TRIM(G2)&"'",1)

With G2 containing Harbor , this returns Iris Chen, Tessa Reed, Priya Shah, and Celia Brooks. It still misses Ellis Grant until the source is cleaned. Without TRIM, that same G2 value matches only Ellis Grant. TRIM handles ordinary spaces. If a pasted value contains a non-breaking space, further cleanup is required.

The header argument should be written in, not guessed

The third QUERY argument is the number of header rows. Leaving it out makes Sheets infer the number, and that inference decides which rows are data.

For the original table, row 1 contains the headings. State that:

=QUERY(A1:E9,"select C where B = 'Ridge'",1)

This returns Felix Park, Julian Moss, and Rowan Bell.

If the range already starts at the first data row, set the header count to 0:

=QUERY(A2:E9,"select Col3 where Col2 = 'Ridge'",0)

This returns the same three names. In this file, omitting the third argument on A1:E9 still treated row 1 as a header, and a one-row range with no header still returned the student name. I still wouldn’t leave the guess in a report. A wrong guess can swallow a data row or treat a heading as a value.

Empty output is not a parse error

“Unable to parse query string” means the second argument isn’t valid QUERY language. In this file, where B = Harbor without quotes returned #VALUE! and “Unable to parse query string for Function QUERY parameter 2: NO_COLUMN: Harbor.” “Query completed with an empty output” means the query ran and matched no rows. The parse problem belongs in QUERY unable to parse. Changing syntax will not create signups for a site and week that have none.

IFERROR around the empty QUERY also displayed No signups. I’d still use IFNA for this #N/A, because IFERROR would also hide a parse error. IFERROR vs IFNA covers that distinction.

FILTER has a different no-match message: “No matches are found in FILTER evaluation.” Excel has no QUERY function. FILTER’s no-match behavior, including Excel’s #CALC!, is in #CALC! and FILTER with no matches.

Once the source is cleaned

For the 16 November Harbor report, the cleaned source should include Priya Shah, Ellis Grant, and Celia Brooks. After the trailing space in B7 is removed, this formula returns those three students with 3, 2, and 2 hours, for a total of 7:

=QUERY(A1:E9,"select C, D, E where B = 'Harbor' and A = date '2026-11-16'",1)

The source-based count is 3:

=COUNTIFS(A2:A9,DATE(2026,11,16),B2:B9,"Harbor")

The source-based hours total is 7:

=SUMIFS(E2:E9,A2:A9,DATE(2026,11,16),B2:B9,"Harbor")

Leave a genuinely empty week as No signups if that helps the coordinator. Keep the count at 0 and the total at 0, calculated from the source rows rather than from a QUERY result that might contain a header or a text fallback.

Oscar

寫 Excel 與 Google Sheets 的公式和排錯。

Google Sheets, 20 November 2026, new private unshared spreadsheet (locale en_US, timezone America/New_York). Week values were entered as user input (2026-11-09 and 2026-11-16) and formatted as DATE yyyy-mm-dd. A separate copy stored the same days as plain serial numbers 46335 and 46342, without a date format, for contrast. Formulas were entered as user input through the Sheets API. Error text was read from the Sheets API error message, not from a hover tooltip. Excel was not run.

本主題下一篇:表格錯誤與動態陣列 Wrong Number of Arguments to IF in Google Sheets