How to Use COUNTIF for True Condition in Google Sheets

By using the COUNTIF function to find TRUE conditions and values in Google Sheets, a business can quickly and easily count the number of times a certain condition, such as “product sold” or “payment received”, is met.

This allows for efficient data analysis and can help inform important business decisions, such as identifying top-selling products or tracking payment trends. Check the following article to grasp the concept of using COUNTIF true in google sheets.

overview image of countif true in google sheets


A Sample of Practice Spreadsheet

You can copy our spreadsheet that we’ve used to prepare this article.


4 Examples to Use COUNTIF for True Condition in Google Sheets

In Google Sheets, there are a few ways to use the COUNTIF function to find “True” values in a range of cells. Check the following section to find out.

1. Simple Boolean Logic Test

The dataset we have contains information about products and their quantity sold. It also has a column indicating whether the product is currently in stock or not, represented by the values “TRUE” or “FALSE“. To find out how many of the products are in stock, we will use a formula to count the number of times the value “TRUE” appears in the stock column.

data for simple boolean logic test

Steps:

  • Firstly, we will select cell D12.

how to select cell in google sheets

  • Secondly, we will use the following formula to count the TRUE Values.
=COUNTIF(D5:D9,TRUE)

using formula for countif true in google sheets

  • Lastly, pressing ENTER will bring forth the result.

final result of countif true in google sheets simple boolean

The result of this formula is “3” as we can see in the image provided, indicating that there are three products currently in stock.

Read More: [Fixed!] COUNTIF Function Is Not Working in Google Sheets


2. Values with Checkbox

Consider that we have a similar dataset. However, Instead of using TRUE or FALSE values, the dataset now uses checkboxes to identify whether the product is still in stock or not.

dataset for values with checkbox

We will use the same formula as before to count the number of products that are marked as in stock by checking for true values in the “In Stock” column.

Steps:

  • Initially, we will select cell D12.
  • Subsequently, we will use the following formula.
=COUNTIF(D5:D9,TRUE)
  • Ultimately, press ENTER to see the result.

countif true in google sheets if values with checkbox

Initially, by examining the image, we can see that the result is 3. This indicates that there are three products currently in stock.

Read More: Use COUNTIF Function to Count Checkbox in Google Sheets


Similar Readings


3. Check Non-Boolean Text

While working on google sheets, we will come across some situations where there will be non-boolean texts such as True or False. The COUNTIF function can only count cells that have a boolean value, so if the cells in the range contain non-boolean values, the function will not be able to count them.

dataset for non boolean text

The True and False values that you see in the image above are text values, not Boolean.

To make the COUNTIF function count the values in the “In Stock” column, we must format the column first. Check the following steps to understand.

Steps:

  • First, we need to select the data range of the “In Stock” column.

selecting a range of data in google sheets

  • Afterward, we will change the data format to Automatic. Therefore, it will convert the non-boolean True or False text into Boolean TRUE or FALSE.

data format from text to automatic in google sheets

  • The resulting dataset looks like this:

final output after data format in google sheets

  • Now, we will select cell D12 to apply the following formula.
=COUNTIF(D5:D9,TRUE)

formula for countif true in google sheets if non boolean text

  • In the end, press ENTER to see the result.

final output for non boolean text in google sheets

We can adjust the dataset to make the COUNTIF function count the values in the “In Stock” column by changing the data format from Plain text to Automatic. This will convert non-boolean text into boolean text values and provide an accurate outcome.

Read More: Google Sheets Count Cells from Another Workbook with COUNTIF Function


4. Count 1 (True) or 0 (False) Outputs

We can convert boolean text or checkboxes into numerical values, such as 1 and 0, in Google Sheets using the ARRAYFORMULA function. This allows us to easily use these values in calculations and functions like COUNTIF.

dataset for count numeric value

Steps:

  • We will begin by creating a new column and labeling it as NUM.
  • Afterward, we will select cell E5 and use the following formula.
=ARRAYFORMULA(--(D5:D9))
  • This formula uses the ARRAYFORMULA function to convert any TRUE or FALSE values in the range D5:D9 to 1 or 0 respectively, by using a double negation () operator.

use of arrayformula to convert boolean values to numeric value

  • Next, in order to count the number of TRUE values, we’ll select cell D12 and input the following formula.
=COUNTIF(F5:F9,1)
  • Press ENTER to apply.

countif 1 or 0 in google sheets

The formula yields the same result as before, which is 3, indicating that there are three products in stock.

Read More: How to Use COUNTIF Function with OR Logic in Google Sheets


Conclusion

The COUNTIF function in Google Sheets with the TRUE or FALSE Boolean criteria allows for powerful data analysis in a business setting. With the ability to quickly and easily count the number of times, certain criteria are met. The function’s flexibility and simplicity make it a valuable tool for any business looking to gain insights from its data. For more insight check our website OfficeWheel.


Related Articles

Ishrak Khan

Ishrak Khan

Ishrak Khan is a writer and urban planner born in Dhaka, Bangladesh, one of the largest mega-cities. He is a professional Content Developer closely working with OfficeWheel. He simply likes to enthrall his readers. He loves Football, Nico Robin, Deserts, and Twix. If you like the post, give him a heart on Instagram.

We will be happy to hear your thoughts

Leave a reply

OfficeWheel
Logo