To compare dollar values in Google Sheets Query, use the WHERE clause with a numeric comparison operator like >, <, >=, or = directly on the column containing the dollar amounts. For example, =QUERY(A1:C10, "SELECT A, B WHERE C > 500") returns rows where column C’s dollar value exceeds 500.
Why Query Instead of FILTER or IF
Query is a single formula that combines filtering, sorting, and selecting columns in one step, which is more efficient than nesting FILTER and IF for large datasets. It also supports SQL-like syntax, making it easier to write complex conditions like comparing two dollar columns against each other. Unlike FILTER, Query can aggregate results (e.g., sum, average) without extra helper columns, and it handles text and numbers more predictably when you use proper formatting.
How Dollar Values Are Stored in Sheets
Dollar values in Google Sheets are stored as numbers, not as text with a currency symbol. The dollar sign you see is just formatting. This is crucial for Query: if you type a dollar sign inside the comparison, like WHERE C > '$500', Query treats it as text and returns no matches or an error. Always use raw numbers in the Query string. To verify, select a cell with a dollar value and check the formula bar—if it shows 500 without a $, it’s numeric.
Basic Query Syntax for Dollar Comparisons
Assume your data has dates in A2:A100, item names in B2:B100, and dollar amounts in C2:C100. The basic structure is:
=QUERY(A2:C100, "SELECT A, B, C WHERE C >= 1000 ORDER BY C DESC", 1)
This returns rows where the dollar value in C is at least 1000, sorted highest first. The third argument 1 tells Query that the range has one header row. If your data has no headers, omit it or use 0. For less than, use <; for exact match, use =.
Comparing Two Dollar Columns
To compare dollar values in two different columns, say column C (budget) and column D (actual spend), you can reference both in the WHERE clause:
=QUERY(A2:D100, "SELECT A, B, C, D WHERE C > D", 1)
This returns rows where the budget exceeds actual spend. You can also compare against a calculated value, like WHERE C > D*1.1 to find budgets more than 10% above spend. Note that you cannot use column aliases (like AS) in the WHERE clause—use the original column letters.
Handling Currency Formatting and Text
If your dollar values are actually stored as text (e.g., imported from a CSV with $ symbols), Query will treat them as strings and numeric comparisons will fail. To fix, convert text to numbers using VALUE() in a helper column: =VALUE(SUBSTITUTE(A2, "$", "")). Then run Query on that helper column. Alternatively, use the QUERY function’s FORMAT clause to display results as currency, but that doesn’t change the underlying comparison. For example, FORMAT C '$0.00' only affects display.
Common Errors and How to Fix Them
- #VALUE! error: Usually means you included a dollar sign or comma in the comparison number. Remove any formatting characters inside the quotes.
- #N/A error: Often because the column letter is wrong or the range doesn’t include the column. Double-check your range and column references.
- Blank rows returned: If your data has blank cells in the dollar column, Query may include them. Add
WHERE C IS NOT NULLto exclude blanks. - Case sensitivity: Query is case-insensitive for text, but for numbers it’s irrelevant. If comparing text columns, use
LOWER()if needed.
Using Query with Currency Conversion or Totals
You can combine comparisons with aggregation. For example, to sum all dollar values over 5000:
=QUERY(A2:C100, "SELECT SUM(C) WHERE C > 5000 LABEL SUM(C) 'Total'", 1)
This returns a single number. To group by category, add a GROUP BY clause: SELECT B, SUM(C) WHERE C > 1000 GROUP BY B. This is useful for comparing dollar totals across categories. For currency conversion, multiply the dollar column by a conversion rate stored in a cell, but that’s outside Query—do it in a helper column first.
Alternatives: FILTER and SORTN
If Query feels complex, use FILTER for simple comparisons: =FILTER(A2:C100, C2:C100 > 500). This returns all columns but doesn’t allow selecting specific columns or sorting. For top N dollar values, use SORTN: =SORTN(A2:C100, 5, 0, C2:C100, FALSE) to get the 5 highest. Query is more powerful when you need multiple conditions, aggregation, or a specific column order. For most dollar comparisons, FILTER is faster to write but Query is more scalable.
Frequently Asked Questions
How do I compare dollar values with a cell reference in Query?
You can concatenate the cell reference into the Query string. For example, if E1 contains the threshold number, use =QUERY(A2:C100, "SELECT A, B, C WHERE C > "&E1, 1). The ampersand joins the text and the cell value. Ensure E1 is a number, not formatted as currency with a $.
Why does my Query return 0 for dollar amounts?
This usually happens when the dollar column is formatted as currency but the actual cell values are text. Check if the cells are left-aligned (text) or right-aligned (numbers). Convert text to numbers using VALUE() in a helper column, or use Data > Split text to columns.
Can I compare dollar values that have commas like 1,000?
Yes, if the cell is a number, commas are just formatting. In the Query string, write the number without commas: WHERE C > 1000. If the cell is text with commas, you must remove them first, e.g., using =VALUE(SUBSTITUTE(A2, ",", "")).
Does Query work with negative dollar values?
Yes, negative numbers work fine. Use WHERE C < 0 to find losses or refunds. Just ensure the cell is numeric; a text like “-500” won’t compare correctly.
How do I compare dollar values across two different sheets?
Use the sheet name in the range, like =QUERY(Sheet2!A2:C100, "SELECT A, B, C WHERE C > 1000", 1). If the sheet name has spaces, wrap it in single quotes: 'Sheet 2'!A2:C100. You can also use IMPORTRANGE for data from another file.
Is there a way to compare dollar values with a percentage threshold?
Yes, use arithmetic in the WHERE clause: WHERE C > D*1.2 to find where column C is more than 20% above column D. Remember that multiplication uses * and parentheses for clarity.
Related
- Data Entry Software Programs: Types & Picks
- Project Slab Pond Table: Build & Design Guide
- How to Make Random Numbers in C++
Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.
More in How-to basics
- Change Date Format to Text in Excel: 3 Reliable WaysTo convert an Excel date into text while controlling how it looks, use the TEXT function, such as…
- Excel Keyboard Shortcut to Select a Row in Any WorksheetIn Excel for Microsoft 365 on Windows, press Shift+Space to select the entire worksheet row containing the active…
- Add a Custom Number Format in Excel: Steps & ExamplesTo add a custom number format in Excel for Microsoft 365 on Windows, select the cells, press Ctrl+1,…
- Excel HR Templates for Attendance: A Practical GuideYes, Excel HR templates for attendance are downloadable spreadsheets that let you log employee work hours, track absences,…
- Excel Protect Sheet but Allow Data Refresh?Usually, Excel cannot refresh data into locked cells on a protected worksheet: sheet protection has no general permission…
- Excel Row Height Shortcut: Set, Adjust, and AutoFit RowsIn Excel for Microsoft 365 on Windows, press Alt, H, O, H in sequence to open the Row…
Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources
Spotted an error in this guide? Let us know.