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 Extract Numbers from Text in Excel with Regex

You can use the REGEXEXTRACT or REGEXREPLACE functions to easily extract numbers from text...

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

How to Use OFFSET and XMATCH Functions Together in Excel

We often use the OFFSET and XMATCH functions together to match a value in...

How to Calculate Maximum Drawdown in Excel and Google Sheets

You can use the following dynamic array formula to calculate maximum drawdown (MDD) in...

More like this

Using OFFSET and MATCH Together in Google Sheets: Advanced Tips

One powerful and flexible way to look up values is by combining the OFFSET...

Running Count with Structured References in Google Sheets

Running a count with structured references is achievable in Google Sheets tables using the...

Running Total with Structured Table References in Google Sheets

You can use two types of formulas to create a running total with structured...

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.