NOT Function in Google Sheets: A Comprehensive Guide

Published on

When you want to reverse the logical result of a condition, either on its own or within other functions, use the NOT function in Google Sheets. The NOT function inverts a logical value—returning TRUE if the input is FALSE, and FALSE if the input is TRUE.

Example:

=NOT(TRUE) // returns FALSE
=NOT(FALSE) // returns TRUE

Let’s explore this with a few examples. But first, here is the syntax of the NOT function in Google Sheets:

NOT(logical_expression)

The logical_expression can be an expression, a cell reference, or a range reference representing a logical value.

If using a range reference, remember to include the ARRAYFORMULA unless the NOT function is used within functions like SORT, SORTN, FILTER, INDEX, and SUMPRODUCT.

Basic Examples of the NOT Function in Google Sheets

If cell B2 contains “Apple”, the following logical expression will return TRUE:

=B2="Apple"

When you use this within the NOT function, the output will be FALSE:

=NOT(B2:B10="Apple")

You can also use this with ARRAYFORMULA to return an array of logical values:

=ARRAYFORMULA(NOT(B2:B10="Apple"))
NOT function with ARRAYFORMULA usage in Google Sheets

Real-Life Use of the NOT Function

In this example, you’ll see how to apply the NOT function in real-life scenarios in Google Sheets. We’ll start with using NOT within the FILTER function, followed by its use with XMATCH.

Example 1:

Suppose you want to extract all fruits except “Apple” in the range B2:B10. Here’s how you can do it:

Enter the condition, e.g., “Apple,” in cell C2.

In D2, enter the following formula:

=ARRAYFORMULA(NOT(B2:B10=C2))

This will return TRUE wherever the fruit in B2:B10 is not “Apple.”

In E2, enter the following FILTER formula:

=FILTER(B2:B10, D2:D10)

This filters the range B2:B10 wherever D2:D10 is TRUE, excluding “Apple.”

NOT function with FILTER function using a single criterion

You can simplify this by replacing D2:D10 directly in the FILTER formula with the logic itself. When doing so, remove ARRAYFORMULA since it’s not required within the FILTER function:

=FILTER(B2:B10, NOT(B2:B10=C2))

Example 2:

Now, let’s say you want to exclude both “Apple” (in C2) and “Mango” (in C3). To filter out both, use the XMATCH function as follows:

In D2, use this formula:

=ARRAYFORMULA(XMATCH(B2:B10, C2:C3))

This will return #N/A for any values in B2:B10 that don’t match “Apple” or “Mango” in C2:C3.

XMATCH for matching criteria

Wrap the formula with IFNA to handle errors (which can be considered as “no match” or FALSE):

=ARRAYFORMULA(IFNA(XMATCH(B2:B10, C2:C3)))

Further, wrap it with the NOT function to flip the TRUE/FALSE logic:

=ARRAYFORMULA(NOT(IFNA(XMATCH(B2:B10, C2:C3))))

Finally, use this within the FILTER function:

=FILTER(B2:B10, NOT(IFNA(XMATCH(B2:B10, C2:C3))))
NOT function with FILTER function using multiple criteria in Google Sheets

This formula will filter out both “Apple” and “Mango” from the range B2:B10. It’s a practical approach that can be applied in many real-life scenarios, so practice with your examples!

Resources

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

How to Create a Searchable Table in Excel Using the FILTER Function

Finding specific records, or rows containing the required information, is straightforward in Excel using...

Time Sequences in Excel by Minute, Hour, or Second Increments

Creating time sequences, whether by hour, minute, or second increments in Excel, can be...

Finding Most Frequent Text in Excel with Dynamic Array Formulas

Looking to identify the most frequently occurring text in Excel? You can do this...

Hierarchical Numbering Sequences in Excel

Creating hierarchical numbering sequences in an Excel spreadsheet can significantly improve the way you...

More like this

XMATCH Row by Row: Finding Values Across a Range in Google Sheets

Using the BYROW function with XMATCH in Google Sheets allows us to match values...

Limit Formula Expansion to a Specific Row in Google Sheets

In this tutorial, I’ll explain how to limit the expansion of an array formula...

3-D Referencing Structured Data Tables in Google Sheets

When you have several tables within a single sheet—not across multiple sheets in a...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.