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.

Compare Two Tables for Differences in Excel

To compare two tables with similar data for differences, you can use the XLOOKUP...

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

How to Retrieve the Last Record in Each Group in Excel

As part of data analysis, you may need to retrieve the last record from...

More like this

Calculate Weighted Average in Pivot Table in Google Sheets

You can calculate a weighted average in a Pivot Table using a custom formula...

Summarize Data and Keep the Last Record in Google Sheets

In Google Sheets, we can summarize data (like sum, average, min, max, count) using...

Filter Data with Multi-Select Drop-Downs in Google Sheets

If you've started using multi-select drop-downs in Google Sheets, you may encounter challenges when...

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.