The label clause in Google Sheets QUERY lets you rename the column headers in the result table. You write it after the main query string, like =QUERY(A1:C10, "select A, B label A 'Name', B 'Score'"), and it replaces the original column letters or names with the text you specify.
What the Label Clause Does
When you run a QUERY, Google Sheets returns columns with default headers: the original column letters (A, B, C) or the first row values if your data has a header row. The label clause overrides those headers for the output only. It does not change your source data.
For example, with data in A1:C10 where A1 is “Product”, B1 is “Units”, and C1 is “Price”, the query =QUERY(A1:C10, "select A, B, C label A 'Item', B 'Quantity', C 'Unit Price'") returns columns headed “Item”, “Quantity”, and “Unit Price”.
You can also use label to give a name to calculated columns. If you compute sum(B), the default header is sum(B), which looks technical. Adding label sum(B) 'Total Units' makes it clear.
Syntax and Placement
The full QUERY syntax is =QUERY(data, query, [headers]). The query string contains the SQL-like instructions. The label clause goes at the very end of that string, after any where, group by, order by, or limit clauses. Separate multiple label assignments with commas.
Correct order example:
=QUERY(A1:C10, "select A, sum(B) where C > 10 group by A label sum(B) 'Total'")
Incorrect order (label before group by) will cause a parse error.
How to Write Label Expressions
Each label expression has two parts: the column reference (like A or sum(B)) and the new name in single quotes. The new name must be enclosed in single quotes. If your label text contains a single quote, escape it by doubling it: label A 'It''s here'.
You can label any column that appears in the select clause. You cannot label a column that is not selected. If you select A, B and try to label C, you get an error.
For columns that use aggregation functions, use the full function expression as the reference. For example, label avg(B) 'Average' or label max(C) 'Highest'.
Common Use Cases and Examples
Here are three practical examples:
- Renaming raw columns:
=QUERY(A1:B10, "select A, B label A 'First Name', B 'Last Name'")– changes headers to human-readable names. - Naming calculated totals:
=QUERY(A1:C10, "select A, sum(B) group by A label sum(B) 'Total Sales'")– gives a clean header for the sum. - Combining with where and order:
=QUERY(A1:C10, "select A, B where B > 100 order by B desc label A 'Product', B 'Units Sold'")– filters and sorts, then renames headers.
Note: If you use label with a column that already has a header from your data, the label overrides it. If you want to keep the original header, you don’t need a label for that column.
Frequently Asked Questions
Can I use label to change the header of a column that has a space in its name?
Yes, but you must reference the column by its letter (like A) or by the full expression. If your data has a header with a space, like “Sales Amount”, you can still select it as A and label it: label A 'Revenue'. You cannot use the name with a space directly in the label reference.
What if I get a parse error when using label?
Parse errors usually come from missing single quotes around the label text, a comma missing between label assignments, or placing the label clause before other clauses. Check that every label text is in single quotes and that the clause is at the end of the query string.
Can I label a column with a number or a date?
Yes, the label text is always a string, even if it looks like a number or date. For example, label A '2024' will show “2024” as text, not as a number. If you need it as a number, you’ll have to convert it separately.
Does label work with pivot clauses?
Yes, you can label columns in a pivot result. For example, =QUERY(A1:C10, "select A, sum(B) pivot C label sum(B) 'Total'"). The label applies to the aggregated column, not the pivot headers.
How do I remove a header entirely with label?
You can set the label to an empty string: label A ''. This will leave the header cell blank. Note that this is different from using the headers argument in QUERY, which controls how many rows are treated as headers in the source data.
Label vs. Headers Argument
The headers argument (the third parameter in =QUERY(data, query, headers)) tells Google Sheets how many rows at the top of your data are header rows. It affects how the QUERY interprets the data, especially when you reference column names. The label clause only affects the output headers. They serve different purposes:
headers– tells the function which rows are headers in the source data (0, 1, or a number).label– renames the columns in the result.
If you set headers to 1, you can use column names in the query (like select Product), but the output still shows those names unless you override with label.
Alternatives to Label
If you need more control over headers, you have other options:
- Use ARRAYFORMULA with a header row: Write a formula like
{"Name", "Score"; ARRAYFORMULA(A1:B10)}to create your own headers. This works for simple cases but doesn’t filter or aggregate. - Use a separate cell to set headers: Put your desired headers in a row above the QUERY result and use the QUERY without a label. This is manual but simple.
- Use the FILTER function: If you only need to filter and rename, FILTER with a manual header row might be easier, but FILTER doesn’t do aggregation.
For most QUERY tasks, label is the cleanest way to rename headers without extra helper rows.
Common Mistakes and Troubleshooting
Here are frequent errors and fixes:
- Missing single quotes: Always put the label text in single quotes. Double quotes will cause a parse error.
- Labeling a column not in select: Ensure the column reference in the label matches exactly what you wrote in the select clause.
- Using a column name with spaces in label reference: Use the column letter or the full function expression, not the header name with spaces.
- Placing label before other clauses: The order must be: select, where, group by, pivot, order by, limit, offset, label. Label is always last.
- Using label with a query that returns no rows: If the query returns no rows, the label still applies to the header row, but you might see only headers.
If you still get an error, copy the query string into a scratch cell and check each clause separately. Removing the label clause often isolates the issue.
Related
- Final Grades and General Average in Excel
- Free Online Data Entry Software: Real Options for 2025
- Google Sheets Power Query Equivalent: 6 Ways
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- How to Resize an Image in an Excel Cell and Keep It FittedTo resize an image so it fits an Excel cell, insert it with Insert > Pictures > Place…
- Daily Cleaning Checklist Template Excel: Setup GuideA daily cleaning checklist template in Excel is a task-by-task log with columns for the date, area, cleaning…
- How to Remove Formatting in Word Without Losing TextTo remove formatting in a Word document, select the text, then choose Home > Clear All Formatting. To…
- Open Excel Solver Add-in: Enable and Use ItTo open Solver in Excel for Microsoft 365 on Windows, enable the Solver Add-in at File > Options…
- Excel Group Rows Shortcut: How to Collapse and ExpandIn Excel for Microsoft 365 on Windows, select the rows you want to group and press Alt+Shift+Right Arrow.…
- Excel Strikethrough Shortcut: How to Cross Out TextIn Excel for Microsoft 365 on Windows, select a cell and press Ctrl+5 to apply strikethrough; press the…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.