Google Sheets is packed with powerful functions, but two often get confused: QUERY and FILTER. Both can help you extract specific data from your spreadsheet, but which one is the right tool for your task?
If you’re new to spreadsheets, don’t worry—this article breaks it all down in simple terms. We’ll walk through how QUERY and FILTER work, when to use each, and a real-world example to see them in action.
What Is the QUERY Function in Google Sheets?
The QUERY function lets you run SQL-like commands on your data. That means you can use terms like SELECT
, WHERE
, ORDER BY
, and LIMIT
—just like working with a database.
It’s extremely flexible and useful when you want to filter, sort, or group data—all in one go.
=QUERY(A1:D10, "SELECT B, C WHERE D > 100", 1)
This formula pulls column B and C from the data range where column D is greater than 100.
What Is the FILTER Function in Google Sheets?
The FILTER function is simpler and more intuitive. It only filters rows that match your given condition(s). Think of it as a lightweight way to isolate data based on criteria.
=FILTER(B2:C10, D2:D10 > 100)
This gives similar results as QUERY, but with less syntax to remember. It’s great for quick filtering tasks.
Side-by-Side Example: Sales Data
Let’s say you manage sales data and want to view only the sales where revenue is greater than $1000.
Sample Data
Salesperson | Region | Revenue |
---|---|---|
John | North | 950 |
Sarah | West | 1250 |
Mike | South | 1700 |
Lily | East | 980 |
Tom | West | 1100 |
Using FILTER:
=FILTER(A2:C6, C2:C6 > 1000)
This shows only rows where revenue is over 1000.
Using QUERY:
=QUERY(A1:C6, "SELECT A, B, C WHERE C > 1000", 1)
Also gives the same filtered result, but you can choose which columns to return and even sort them.
When to Use QUERY vs FILTER
- Use FILTER if:
- You want something fast and easy
- Your filtering logic is simple
- You’re okay with returning all columns in the same order
- Use QUERY if:
- You want more control (select specific columns)
- You need to
GROUP BY
or sort results - You prefer a database-style approach
Advantages of Each Function
Advantages of FILTER:
- Simple syntax
- Faster for basic filters
- Easier for beginners
Advantages of QUERY:
- Powerful and flexible
- Can sort, limit, group, and filter in one formula
- Works well with large datasets
Quick Comparison Table
Feature | FILTER | QUERY |
---|---|---|
Ease of Use | Easy | Intermediate |
Can Select Specific Columns | No | Yes |
Can Sort Data | No | Yes |
SQL-Like Syntax | No | Yes |
Ideal for Complex Filtering | Limited | Excellent |
Quick Cheat Sheet
- FILTER syntax:
=FILTER(range, condition)
- QUERY syntax:
=QUERY(data, "SELECT ... WHERE ...")
- FILTER pros: Easy, readable, fast
- QUERY pros: Advanced filtering, sorting, grouping
Both QUERY and FILTER are excellent tools, and the one you choose depends on your comfort level and what you need to do. For quick and easy filtering, FILTER is your friend. But if you want to take your spreadsheet skills to the next level, QUERY opens up a world of possibilities.
Give them both a try with your data—you’ll quickly see how each has its place in your Google Sheets toolkit.