Google Sheets Query Label Multiple Columns

How-to basics · Updated November 23, 2026

Yes, you can label multiple columns in a single Google Sheets QUERY function by using multiple label clauses separated by commas inside the same clause, like label A 'Name', B 'Score'. The label clause is part of the QUERY’s syntax and lets you rename column headers in the result without altering the source data.

What the label Clause Does

In Google Sheets, the QUERY function uses a Google Visualization API Query Language. The label clause renames the column headers that appear in the output. It does not change the underlying data or the original column names in your sheet. You can apply labels to any column that appears in the select clause, whether it’s a raw column reference (like A or C) or an aggregated column (like sum(B) or count(A)).

For example, if you have data in columns A and B, and you want to display them with custom headers, you write:

=QUERY(A1:B10, "select A, B label A 'Product', B 'Units Sold'", 1)

This returns two columns, with the headers “Product” and “Units Sold” instead of “A” and “B”. The 1 at the end tells QUERY that the data has one header row, which is ignored in the query but preserved in the output.

Syntax for Multiple Labels

The label clause follows this pattern: label column1 'Label1', column2 'Label2', .... You separate each label assignment with a comma. The column reference must match exactly how it appears in the select clause. For instance, if you use an aggregation like sum(B), the label must refer to sum(B)—not just B.

Here’s a concrete example with aggregated data. Suppose you have sales data in columns A (region), B (product), and C (amount). You want to count products per region and sum the amounts:

=QUERY(A1:C100, "select A, count(B), sum(C) group by A label count(B) 'Product Count', sum(C) 'Total Amount'", 1)

This returns three columns: A (region), count(B), and sum(C). The labels rename the last two to “Product Count” and “Total Amount”. Note that you don’t need to label column A unless you want to rename it too.

How to Choose Label Names

Label names must be enclosed in single quotes. If your label itself contains a single quote, you can escape it by doubling it (e.g., 'It''s Total'). You can also use double quotes for the entire label string, but then you must escape double quotes inside. In practice, single quotes are simpler.

When deciding what to label, think about what the reader sees. Labels are especially useful when you use formulas that return cryptic column names like sum(B) or when you want to present a report to someone who doesn’t know the raw column letters. You can also use labels to add units or clarify abbreviations, such as 'Revenue ($)' or 'Qty'.

Common Mistakes and Fixes

  • Mismatched column reference: If you label B but your select uses sum(B), you’ll get an error. Fix: use the exact same reference in the label.
  • Missing comma between labels: Each label assignment must be separated by a comma. Forgetting a comma causes a parse error.
  • Using double quotes inside single-quoted labels: That’s fine, but if you need a single quote inside the label, double it. Example: label A 'Manager''s Report'.
  • Labeling a column not in select: QUERY only allows labels for columns that appear in the output. If you try to label a column you didn’t select, you get an error.
  • Forgetting the header row parameter: If your data has headers, include the third argument (1) to avoid treating the header as data. Without it, your labels might shift.

Labeling with Format Clauses

You can combine label with format to change both the header and the number/date display. For example, to format a sum as currency and label it:

=QUERY(A1:C100, "select A, sum(C) group by A label sum(C) 'Total' format sum(C) '$#,##0.00'", 1)

The format clause uses Google’s number format patterns. You can apply multiple formats similarly, separating them with commas. This is powerful for financial reports where you want clean headers and readable numbers.

Differences from Excel

Excel does not have a QUERY function. The closest equivalents are FILTER, UNIQUE, and SUMIFS, but none of them allow renaming headers directly. In Excel, you would typically use a helper row or a table with custom headers, or use Power Query (Get & Transform) to rename columns. If you’re migrating a Google Sheets QUERY to Excel, you’ll need to restructure the formula or use a pivot table.

In Google Sheets, the QUERY function is unique because it combines SQL-like syntax with spreadsheet data. The label clause is one of its most user-friendly features, saving you from manually copying and pasting headers.

Frequently Asked Questions

Can I label a column that is a calculated field like A+B?

Yes. If you use a calculated column in the select clause, you can label it. For example, select A, B, A+B label A+B 'Total'. The label reference must match the expression exactly, including the plus sign and spaces (though spaces are optional). If you write A + B in select, use the same in label.

Why does my label not show up when I use a pivot?

QUERY’s label works only with the QUERY function, not with pivot tables. If you’re using a pivot table, you rename headers by clicking on the header cell and typing a new name, or by editing the field settings. QUERY and pivot tables are separate features.

Can I use a cell reference for the label text?

No, the label text must be a literal string inside the query string. You cannot directly reference a cell like label A & D1 because the query is a text string. However, you can build the query string using concatenation, like "select A label A '"&D1&"'", but that makes the formula harder to read and maintain.

What happens if I don’t use a label clause at all?

Without a label clause, QUERY returns the column letters (like A, B) or the aggregation expression (like sum(B)) as headers. That’s often not user-friendly, which is why labels are recommended for any report you share.

Can I label columns when using QUERY with a different sheet or range?

Yes, the label clause works regardless of the data source. The column references in the label must match the column letters in the range you specify. For example, if you query 'Sheet2'!A1:C10, you still use A, B, C in the label.

Is there a limit to how many columns I can label?

No hard limit is documented, but practical limits come from the overall QUERY string length (Google Sheets has a 50,000 character limit for formulas). You can label every column in your select clause if needed.

Practical Example with Real Data

Imagine you have a student gradebook with columns: A (Student Name), B (Math), C (Science), D (English). You want a summary showing each student and their average score, with a custom header “Average”. Here’s the formula:

=QUERY(A1:D20, "select A, (B+C+D)/3 label A 'Student', (B+C+D)/3 'Average Score'", 1)

This returns two columns: Student and Average Score. The arithmetic expression (B+C+D)/3 is used identically in both select and label. This works because QUERY evaluates the expression and you can label it.

If you want to round the average to two decimals, you can use round((B+C+D)/3, 2) in select and label that same expression. Always keep the label reference exactly matching the select expression to avoid errors.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.