Google Sheets QUERY Builder

Pick columns, filters, grouping and sorting from menus and get a correctly quoted QUERY formula, an explanation of every clause and a preview of the result.

S'executa al teu navegador. Els fitxers mai no surten del dispositiu. Mira com comprovar-ho

…

Com es fa

  1. 1
    Paste sample data

    Press Your data and paste a few rows with the header row.

  2. 2
    Set the range

    Type the range the formula will read and the number of header rows.

  3. 3
    Choose columns

    Add columns under Select and pick an aggregate where needed.

  4. 4
    Filter and group

    Add Where conditions, tick Group by columns and pick a pivot if wanted.

  5. 5
    Sort and trim

    Add Order by entries and set Limit and Offset.

  6. 6
    Copy

    Check the preview and the explanation, then press Copy formula.

Sobre aquesta eina

The QUERY function is the most powerful formula in Google Sheets and also the easiest to get wrong. Its query string is a small language of its own, column letters change meaning when the range does not start at column A, text values need single quotes, dates need the date keyword in ISO form, and the whole query sits inside a formula string where double quotes must be doubled. This builder removes that friction. You paste a few rows of the data you plan to query, header row included, and assemble the query from menus: which columns to return and whether to sum, average, count, take the minimum or the maximum; which conditions rows must meet, joined with and or or and optionally negated; which columns to group by; an optional pivot column; the sort order; limit and offset; and labels and number formats for the result. The formula updates as you click, with the clause keywords highlighted, and a Copy formula button puts it on your clipboard ready to paste into a cell.

Preview that behaves like Sheets

The preview runs the same query on your pasted rows. Column types are decided the way QUERY decides them, by the majority type of the values in each column, so a column of mostly numbers with a few text cells is treated as numeric and the text cells become empty. Text comparisons with contains, starts with and ends with are case sensitive, like is supported with % for any run and _ for one character, and matches takes a regular expression that has to match the whole value. Grouped queries enforce the real rule that every selected column must either be aggregated or appear in group by; if the rule is broken, the preview says so instead of guessing, which is exactly the situation where Sheets would show an error.

Explanation panel

Every clause gets a sentence in plain English, so the formula can be pasted into a shared sheet with a note, or used to learn the syntax. The panel names each column by its letter and its header, which helps when the range starts at a column other than A.

Column references

Choose letters for ordinary ranges and Col1, Col2 style for data that comes from an array literal, from IMPORTRANGE or from another function, where QUERY does not accept letters.

Limits

The preview applies the logic of the query but not the number and date patterns of the format clause; Sheets applies those when the formula runs. Scalar functions such as year(), month() and upper(), arithmetic between columns and the options clause are not offered in the menus, though they can be typed into the formula after copying. Results on very large sheets can differ where Sheets reads mixed-type columns differently from a small pasted sample, so test the formula on the real sheet before relying on it.

Exemple resolt

A sales sheet has columns Date, Region, Rep, Product, Units and Revenue in A1:F. Selecting Region and the sum of Revenue labelled Revenue, with Date on or after 2026-02-01, grouped by Region and sorted by sum of Revenue high to low, gives =QUERY(Sales!A1:F, "select B, sum(F) where A >= date '2026-02-01' group by B order by sum(F) desc label sum(F) 'Revenue' format sum(F) '#,##0'", 1). On the sample rows the preview shows East 2,083, North 1,936 and South 2,404 before sorting, so South comes first.

En resum

Preguntes freqüents

Why does my formula use letters that differ from my headers?

QUERY refers to columns by sheet letter, not by header. The builder shows both side by side so you can check them.

How are text values with an apostrophe handled?

They are wrapped in double quotes inside the query, and those quotes are doubled in the formula, which is what Sheets expects.

Why does the preview say a column must be in group by?

When any column is aggregated, every other selected column has to be grouped. Sheets returns an error otherwise.

How do I filter dates?

Pick the date column, an operator and type the date as yyyy-mm-dd. The builder writes it with the date keyword.

What does pivot do?

It turns every distinct value of one column into its own result column, like a pivot table built by formula.

Is my sheet data sent anywhere?

No. Pasted rows stay in the browser and the preview runs locally.

Totalment gratisSense cost, sense registre
Els fitxers es mantenen privatsTot funciona al teu navegador
Fàcil en el teu idiomaDisponible en molts idiomes