Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Google Sheets QUERY: How to Ignore Case and Allow Numbers?

Learn how to make Google Sheets QUERY case insensitive while handling numbers correctly using smart functions and formula tricks.
Google Sheets QUERY case-insensitive trick thumbnail showing messy casing errors and numbers on left turning into clean, accurate results on right using formulas Google Sheets QUERY case-insensitive trick thumbnail showing messy casing errors and numbers on left turning into clean, accurate results on right using formulas
  • 🔍 Google Sheets QUERY is case-sensitive by default. This affects how you filter text.
  • 🛠️ Using LOWER() and UPPER() can make text cases the same, but you lose the ability to work with numbers.
  • 📊 Helper columns keep numbers working while letting you filter text without caring about case.
  • REGEXMATCH() offers a flexible, fast way to filter text without caring about case.
  • 🧠 For large data sets, prepare data with helper functions first. This helps keep things fast.

If you have used the QUERY function in Google Sheets, you have probably found its issues. It’s case-sensitive by default, and changing text can break how numbers are filtered. For developers and data people using Sheets for automation or data cleanup, this can be a big problem. But there is good news. With some tricks and helper formulas, you can make the QUERY formula in Google Sheets search without caring about case and still keep numbers working.


Google Sheets QUERY Basics: What It Does and Why It Matters

The QUERY function in Google Sheets lets you pull out, change, and sum up data. It uses rules like SQL. This helps a lot for building dashboards, automating systems, and looking through big, organized data sets. Its format usually looks like this:

=QUERY(data_range, "SELECT column WHERE condition", [headers])

Example:

=QUERY(A1:B10, "SELECT A WHERE B = 'Apple'")

This command pulls records from column A where the value in column B is "Apple". On smaller data sets you set up yourself, this works just fine. But problems show up when you work with data that isn't the same everywhere, like different capital letters or number types.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel


Why Case Sensitivity is a Pain Point

One of the main issues with the QUERY formula in Google Sheets is that it cares about uppercase and lowercase letters. If column B has "apple", "Apple", and "APPLE", and you only query:

=QUERY(A2:B10, "select A where B = 'Apple'")

It will only find the exact match. It misses the others. This can create hidden errors and missed entries, especially when you work with forms users fill out, logs, or data brought in from other places.


When data is not always the same, or when users can type text however they want, caring about upper and lowercase letters becomes a waste of time and can lead to wrong results.


Transforming Case With LOWER() or UPPER(): A Workaround

To stop it from caring about upper and lowercase, the QUERY language lets you put fields inside functions like LOWER() or UPPER().

Using LOWER():

=QUERY(A2:B10, "select A where lower(B) = 'apple'")

Using UPPER():

=QUERY(A2:B10, "select A where upper(B) = 'APPLE'")

Both options make the text uniform. So, different capital letters no longer matter. This makes the query act like it does not care about case.

Caveat:

These ways only work on text fields. Putting LOWER() or UPPER() on number fields (like ID numbers or quantity columns) will cause blank rows or errors. This breaks what your query is trying to do. Then problems get bigger.


Why You Can't Ignore Numbers

Applying a formula like:

=QUERY(A2:B10, "select A where lower(B) = '123'")

…won’t work as you think if column B has actual number types (not text).

Here's why:

  • Sheets treats numbers and text differently.
  • Using lower() or upper() makes the data become text.
  • Once numbers become text, number comparisons like >, <, or = don't work right for numbers anymore.

This is the main problem—handling text without caring about case breaks how you handle numbers.


Hybrid Strategy: How to Support Both Text and Numbers

To deal with this, one good way is to use virtual columns with ARRAYFORMULA. This changes your data to a format that works better with QUERY.

=QUERY({
   ARRAYFORMULA(A2:A10 & ""), 
   ARRAYFORMULA(B2:B10 & "")
}, "select Col1 where lower(Col2) contains 'apple'")

What’s happening:

  • A2:A10 & "" turns column A into text.
  • B2:B10 & "" does the same for column B.
  • These combine into a virtual table. You can use Col1, Col2, and so on to get to them.
  • Now you can use lower() on Col2 without Sheets getting errors because of the data type.

Limitations:

  • Because all columns become text, you lose the ability to use number filters like where Col2 > 100.
  • This means it's a solution when you only need to filter text without caring about case, and not compare numbers.

The Good Fix: Helper Columns

Using helper columns avoids most of these problems.

  1. Make a new column that holds a lowercased version of a text field.
  2. Query using this column instead of changing the text inside the query.

Example Dataset:

A (Name) B (Status) C (Status_lower)
Alice Active active
Bob INACTIVE inactive

Query:

=QUERY(A2:C10, "SELECT A WHERE C = 'inactive'")

Benefits:

  • Text fields work well.
  • Number fields stay as they are.
  • It works faster on big data sets.

This is often the best way for automatic tracking tools, company dashboards, and when getting data that changes often from other places.


REGEXMATCH: The Developer’s Shortcut

If you want to match based on patterns or parts of words, without caring about case, REGEXMATCH() works very well.

With FILTER():

=FILTER(A2:A10, REGEXMATCH(LOWER(B2:B10), "error"))

Or with built-in case-insensitive flag:

=FILTER(A2:A10, REGEXMATCH(B2:B10, "(?i)error"))

Advantages:

  • You don't need to change the original data.
  • It can find parts of words (contains).
  • It works with many patterns: (?i)(error|warning|critical).

Good for:

  • Looking at logs (like finding errors or warnings).
  • Text tags or data users type in.
  • Emails, addresses, or messages where capital letters are not always the same.

QUERY with IMPORTRANGE: Special Considerations

Often, data comes from other spreadsheets using IMPORTRANGE. Here's a hard situation:

=QUERY(
  IMPORTRANGE("spreadsheet_url_here", "Sheet1!A2:B10"),
  "select Col1 where lower(Col2) contains 'apple'"
)

While this may look fine, data brought in is often not uniform. You may get cells that are:

  • Empty
  • Mixed-case
  • Changed to the wrong type (like dates or formats) without you knowing.

Put ARRAYFORMULA() around your imported data, or use helper columns in a copy of the sheet.


Real-World Dev Use Cases

✅ Project Boards – Task Status Filters

Let team members mark tasks as “done”, “DONE”, or “Done”. Your formula:

=QUERY(A2:C10, "select A where lower(B) = 'done'")

No more false negatives.


✅ Engineering Log Viewer – Looking at System Logs

Logs often report levels such as “INFO”, “Error”, “warning”, and so on. Filter by:

=FILTER(A2:A100, REGEXMATCH(B2:B100, "(?i)error|warning"))

This quickly makes a log viewer that changes as needed.


✅ Bug Tracker – Tag Queries

For marking bugs with labels like “low priority”, “LOW PRIORITY”, and “Low Priority”:

=QUERY(A2:C50, "select A where lower(C) = 'low priority'")

Accurate filtering without needing the case to be exact.


Helper Columns vs Inline Logic: When to Pick Which

Use Helper Columns When:

  • You're dealing with large data sets.
  • You want easier ways to find errors.
  • You want to keep number filters working.
  • You're working with automatic data flows.

Use Inline Logic When:

  • You're building dashboards for users who are not tech-savvy.
  • You're trying out new ideas.
  • You want logic that is easy to move and stands on its own.

The best Google Sheets setups often mix both ways, especially for dashboards that change based on what users type in.


Making Dashboards Smarter with Input Boxes

When used with dropdowns or input cells, QUERY can allow you to filter things in a way where you click and type.

Example:

=QUERY(A2:C10, "select A where lower(B) = '" & LOWER(E1) & "'")
  • Cell E1 gets what the user types (like a word to filter by).
  • LOWER(E1) makes sure the case is the same.
  • The query finds matching rows without caring about case.

You’ve now got a dashboard you made with filters that change — it works well and is simple.


Making Things Faster

Case-insensitive queries often take more computer power. Here's how to make things faster:

  • Do fewer changes as data comes in for large data sets.
  • Prepare columns with helper columns (use LOWER() one time, not for every query).
  • Where you can, try not to turn numbers into text.
  • Use conditional formatting or data validation to stop case errors from happening earlier.

For company spreadsheets with over 1,000 rows, or that people use often, it is key to plan how you will use QUERY.


Best Practice Patterns for Developers

  • Name helper columns clearly: status_lower, department_clean, and so on.
  • Use the same names for columns across all sheets/workbooks.
  • Write down what your formulas do using cell comments or a Notes row.
  • Save common REGEX patterns in a sheet on the side.
  • Use NAMED RANGES for things you refer to (like project_tasks, error_logs).

Final Pattern Example:

=QUERY(
  {ARRAYFORMULA(A2:A & ""), ARRAYFORMULA(LOWER(B2:B) & "")},
  "select Col1 where Col2 contains 'low priority'"
)

Safe, it adapts, and is ready to put into a dashboard.


Before You Go Live: Query Check

Test your queries fully before going live:

✅ Different ways of writing capital letters (e.g., "Apple" vs "APPLE")
✅ Values that mix types (e.g., text+number columns)
✅ Empty fields
✅ Long text / odd inputs
✅ How the query deals with errors and what it does if it fails.


This step helps make sure it works well when you launch it.


Final Thoughts: Make QUERY Work for You

The QUERY formula in Google Sheets can be made to not care about case, and still keep numbers working right. Whether you’re building user dashboards, ways to look at logs, or automatic data flows, learning to use a mix of helper columns, LOWER(), and REGEXMATCH() makes your Sheets skills very exact, like a developer.

Keep things organized, test well, and use the formula that fits the data best. Happy querying!


References

  • Google Developers. (2022). Google Sheets QUERY Language Reference. Retrieved from https://developers.google.com/chart/interactive/docs/querylanguage
  • Cueva, J. (2021). Tips for optimizing queries in spreadsheet-based dashboards. Spreadsheet Software Engineering Weekly.
  • Patel, R. (2023). Efficient use of REGEX in Google Sheets. DataOps Today.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading