0
0
Google Sheetsspreadsheet~5 mins

QUERY function basics in Google Sheets - Step-by-Step Guide

Choose your learning style9 modes available
Introduction
The QUERY function lets you pull and filter data from a table using simple commands. It helps you get only the data you want without changing the original table.
When you want to see only sales data for a specific month from a big list.
When you need to list all employees from a certain department without copying rows manually.
When you want to sum or count data based on conditions, like total sales over $1000.
When you want to sort data by date or name without changing the original order.
When you want to create a smaller table from a big one for easier reading or printing.
Steps
Step 1: Click
- a blank cell where you want the result
The cell is selected and ready for typing
Step 2: Type
- the formula bar
The formula starts appearing in the cell
💡 Start with =QUERY(
Step 3: Enter
- the range of your data inside the formula
The formula knows which data to look at
💡 Example: A1:D20
Step 4: Type
- the query string inside the formula
The formula filters or sorts data as you want
💡 Example: "select A, B where C > 100"
Step 5: Close
- the formula with a parenthesis and press Enter
The filtered or sorted data appears in the selected cell and below
Before vs After
Before
A table with 20 rows of sales data including columns Date, Product, Sales, Region
After
A smaller table showing only Product and Sales columns where Sales are greater than 100
Settings Reference
Data range
📍 Inside the QUERY formula as the first argument
Defines which data the QUERY function will use
Default: No default, must specify
Query string
📍 Inside the QUERY formula as the second argument
Tells QUERY how to filter, sort, or select data
Default: No default, must specify
Headers
📍 Inside the QUERY formula as the optional third argument
Specifies how many header rows are in the data range
Default: 1
Common Mistakes
Not putting the query string inside double quotes
QUERY needs the query text as a string to understand it
Always write the query like "select A, B where C > 100" with quotes
Using wrong column letters in the query
QUERY uses column letters from the data range, not the sheet columns
Count columns from the left of your range and use those letters (A, B, C...)
Not closing the formula with a parenthesis
The formula will show an error and not work
Always end the formula with a closing parenthesis )
Summary
QUERY lets you filter and sort data easily using simple commands.
You must specify the data range and write the query string inside quotes.
Remember to use correct column letters based on your data range.