How to Use Comparison Operators in Google Sheets (With Examples)

Published: September 26, 2024 - 8 min read

Vijay Srinivas

Comparison operators in Google Sheets are essential tools for data analysis and decision-making. This comprehensive guide will walk you through the process of using these powerful operators, from basic concepts to advanced techniques. By the end of this tutorial, you’ll be able to create complex formulas, automate data validation, and build dynamic dashboards using comparison operators in Google Sheets.

Basic Comparison Operators in Google Sheets

Let’s explore each comparison operator in detail, along with examples of how to use them in formulas.

Equal To (=)

The ‘equal to’ operator (=) checks if two values are exactly the same.

Syntax: =A1=B1

Example:

A1: 10

B1: 10

Formula: =A1=B1

Result: TRUE

Image12

Note: For text comparisons, the equal to operator is case-insensitive by default.

Not Equal To (<>)

The not equal to operator (<>) checks if two values are different.

Syntax: =A1<>B1

Example:

A1: Apple

B1: Banana

Formula: =A2<>B2

Result: TRUE

Image9

Greater Than (>)

The greater than operator (>) checks if the first value is larger than the second value.

Syntax: =A1>B1

Example:

A1: 15

B1: 10

Formula: =A1>B1

Result: TRUE

Image16

Less Than (<)

The less than operator (<) checks if the first value is smaller than the second value.

Syntax: =A1<B1

Example:

A1: 5

B1: 10

Formula: =A1<B1

Result: TRUE

Image7

Greater Than or Equal To (>=)

The greater than or equal to operator (>=) checks if the first value is larger than or equal to the second value.

Syntax: =A1>=B1

Example:

A1: 10

B1: 10

Formula: =A1>=B1

Image24

Result: TRUE

Less Than or Equal To (<=)

The less than or equal to operator (<=) checks if the first value is smaller than or equal to the second value.

Syntax: =A1<=B1

Example:

A1: 8

B1: 10

Formula: =A1<=B1

Image26

Result: TRUE

Using Comparison Operators in Formulas

Now that we’ve covered the basic operators, let’s explore how to use them in more complex formulas and scenarios.

Creating simple comparison formulas

  1. Open your Google Sheets document.
  2. Click on the cell where you want to enter the formula.
  3. Type an equals sign (=) to start the formula.
  4. Enter the first value or cell reference.
  5. Type the comparison operator.
  6. Enter the second value or cell reference.
  7. Press Enter to complete the formula.

Example:

A1: 15

B1: 20

C1 Formula: =A1<B1

Image22

C1 Result: TRUE

Combining comparison operators with functions

You can use comparison operators within various Google Sheets functions to create more complex formulas.

Example using the COUNTIF function:

  1. Enter some numbers in cells A1:A10.
  2. In cell B1, type the following formula: =COUNTIF(A1:A10, “>5”)
Image25
  1. Press Enter. This formula will count how many cells in the range A1:A10 contain a value greater than 5.

Using comparison operators in conditional formatting

Conditional formatting allows you to apply visual styles to cells based on specific conditions. Here’s how to use comparison operators for conditional formatting:

  1. Select the range of cells you want to format.
  2. Click on “Format” in the menu, then choose “Conditional formatting.”
Image15
  1. In the sidebar, click on “Add another rule.”
Image20
  1. Under “Format cells if…,” choose “Custom formula is.”
Image5
  1. Enter a formula using comparison operators, e.g., =$A1>10
Image1
  1. Set the formatting style you want to apply.
  2. Click “Done.”
Image13

This will apply the chosen formatting to cells where the value in column A is greater than 10.

Nesting comparison operators for complex conditions

You can create more complex conditions by nesting comparison operators using parentheses and logical functions like AND and OR.

Example:

=AND(A1>10, B1<20, C1=D1)

This formula will return TRUE only if all three conditions are met: A1 is greater than 10, B1 is less than 20, and C1 is equal to D1.

Image14

Advanced Techniques with Comparison Operators

Let’s explore some advanced techniques that combine comparison operators with other functions to create powerful formulas.

Using the IF function with comparison operators

The IF function allows you to perform conditional logic based on comparison operators. Here’s the basic syntax:

=IF(logical_test, value_if_true, value_if_false)

Example:

A1: 75

Formula: =IF(A1>=70, “Pass”, “Fail”)

Image27

Result: “Pass”

Coefficient Excel Google Sheets Connectors
Try the Free Spreadsheet Extension Over 425,000 Pros Are Raving About

Stop exporting data manually. Sync data from your business systems into Google Sheets or Excel with Coefficient and set it on a refresh schedule.

Get Started

This formula checks if the value in A1 is greater than or equal to 70. If true, it returns “Pass”; otherwise, it returns “Fail.”

Implementing the OR function for multiple comparisons

The OR function allows you to check multiple conditions and returns TRUE if any of the conditions are met.

Syntax: =OR(condition1, condition2, …)

Example:

A1: 15

B1: 20

C1: 25

Formula: =OR(A1>30, B1>30, C1>30)

Result: FALSE

Image2

This formula checks if any of the values in A1, B1, or C1 are greater than 30.

Combining AND and OR functions with comparison operators

You can create complex logical expressions by combining AND and OR functions with comparison operators.

Example:

A1: 15

B1: 20

C1: 25

Formula: =AND(A1>10, OR(B1>25, C1>20))

Result: TRUE

Image3

This formula checks if A1 is greater than 10 AND either B1 is greater than 25 OR C1 is greater than 20.

Working with text comparisons using operators

When comparing text values, remember that Google Sheets is case-insensitive by default. However, you can use the EXACT function for case-sensitive comparisons.

Example:

A1: “Apple”

B1: “apple”

Formula 1 (case-insensitive): =A1=B1

Result 1: TRUE

Image21

Formula 2 (case-sensitive): =EXACT(A1,B1)

Result 2: FALSE

Image19

Practical Examples and Use Cases

Let’s explore some real-world scenarios where comparison operators can be particularly useful in Google Sheets.

Creating dynamic dashboards with comparison operators

You can use comparison operators to create dynamic dashboards that update based on user input or changing data.

Example: Creating a budget tracker

  1. In cell A1, enter “Budget Category“.
  2. In cell B1, enter “Budgeted Amount“.
  3. In cell C1, enter “Actual Spent“.
  4. In cell D1, enter “Status“.
  5. Fill in categories, budgeted amounts, and actual spent in columns A, B, and C.
  6. In column D, use this formula: This formula will automatically update =IF(C2>B2, “Over Budget”, IF(C2=B2, “On Budget”, “Under Budget”))
  7. the status based on the comparison between budgeted and actual amounts.
Image18

Automating data validation using comparison operators

Comparison operators can be used to create custom data validation rules in Google Sheets.

Example: Ensuring entered values fall within a specific range

  1. Select the cells you want to apply validation to.
  2. Go to Data > Data validation.
Image11
  1. Click “Add rules
Image8
  1. Under “Criteria,” choose “Custom formula is.”
Image6
  1. Enter a formula like =AND(A1>=0, A1<=100)
Image23
  1. Set an appropriate error message.
  2. Click “Done.”
Image10

This will ensure that only values between 0 and 100 can be entered in the selected cells.

Building custom KPI trackers with comparison logic

You can use comparison operators to create sophisticated Key Performance Indicator (KPI) trackers.

Example: Sales team performance tracker

  1. In column A, list sales team members.
  2. In column B, enter their sales targets.
  3. In column C, enter their actual sales.
  4. In column D, use this formula to calculate performance: =IF(C2>=B2, “Met Target”, IF(C2>=B2*0.9, “Close”, “Needs Improvement”))

This formula will categorize each team member’s performance based on how close they are to their target.

Image4

Understanding Comparison Operators in Google Sheets

Comparison operators are symbols used in formulas to compare values and return a logical result (TRUE or FALSE). These operators are fundamental to creating conditional statements and performing data analysis in spreadsheets.

What are comparison operators?

Comparison operators are symbols that allow you to compare two values or expressions. In Google Sheets, these operators include:

  • Equal to (=)
  • Not equal to (<>)
  • Greater than (>)
  • Less than (<)
  • Greater than or equal to (>=)
  • Less than or equal to (<=)

These operators can be used with numbers, text, and dates to create logical expressions that evaluate to either TRUE or FALSE.

Why use comparison operators in spreadsheets?

Comparison operators are crucial for several reasons:

  1. Data validation: They help ensure data accuracy by comparing entered values against predefined criteria.
  2. Conditional formatting: You can use comparison operators to apply visual formatting based on specific conditions.
  3. Data analysis: These operators enable you to filter, sort, and categorize data based on various criteria.
  4. Decision-making: By incorporating comparison operators into formulas, you can create automated decision-making processes within your spreadsheets.

Google Sheets vs. Excel: Differences in comparison operators

While Google Sheets and Excel share many similarities, there are some key differences in how they handle comparison operators:

OperatorMeaningExampleEquivalent Function
=Equal to=A1=B1EQ(A1,B1)
<>Not equal to=A1<>B1NE(A1,B1)
>Greater than=A1>B1GT(A1,B1)
<Less than=A1<B1LT(A1,B1)
>=Greater than or equal to=A1>=B1GTE(A1,B1)
<=Less than or equal to=A1<=B1LTE(A1,B1)

Elevate Your Spreadsheet Game with Comparison Operators

Mastering comparison operators in Google Sheets opens up a world of possibilities for data analysis, automation, and decision-making. By understanding the nuances of each operator and learning to combine them with Google Sheets’ powerful functions, you’ll be well-equipped to tackle complex data challenges and extract meaningful insights from your spreadsheets.

As you continue to explore the potential of comparison operators, remember that practice makes perfect. Experiment with different scenarios, challenge yourself to solve real-world problems, and don’t be afraid to push the boundaries of what’s possible with Google Sheets.

Ready to take your data analysis to the next level? Discover how Coefficient can supercharge your Google Sheets experience with seamless data integration and real-time updates. Get started with Coefficient today and unlock the full potential of your spreadsheet data!

Sync Live Data into Your Spreadsheet

Connect Google Sheets or Excel to your business systems, import your data, and set it on a refresh schedule.

Try the Spreadsheet Automation Tool Over 500,000 Professionals are Raving About

Tired of spending endless hours manually pushing and pulling data into Google Sheets? Say goodbye to repetitive tasks and hello to efficiency with Coefficient, the leading spreadsheet automation tool trusted by over 350,000 professionals worldwide.

Sync data from your CRM, database, ads platforms, and more into Google Sheets in just a few clicks. Set it on a refresh schedule. And, use AI to write formulas and SQL, or build charts and pivots.

Vijay Srinivas GTM @ Coefficient
Vijay Srinivas is an engineer turned marketer who loves to dabble in data and has 6 years of experience in GTM for Startups and SaaS orgs. Building his skills currently to be a PLG & spreadsheet expert.
500,000+ happy users
Wait, there's more!
Connect any system to Google Sheets in just seconds.
Get Started Free

Trusted By Over 50,000 Companies