How to Use the COUNT Function using Query function

The COUNT function in Google Sheets is used to count the number of numeric values in a specified range. You can use the COUNT function along with the QUERY function to filter and count the values based on certain conditions.

Here's how to use the COUNT function using the Query function in Google Sheets:

  1. Open your Google Sheet.
  2. Identify the data range that you want to query and count.


Assume we have the following dataset in a Google Sheet:

Name City Age
Alice New York 25
Bob New York 30
Carol Los Angeles 28
David New York 35
Eve Los Angeles 24

Let's say you want to count the number of people living in New York. You would use the QUERY and COUNT functions as follows:

  1. In an empty cell, type the following formula:
  1. Press the 'Enter' key.

In this formula, A1:C6 is the range of data, and the query string SELECT COUNT(C) WHERE B = 'New York' is used to count the number of values in column C (Age) where the value in column B (City) is "New York".

After executing the formula, the result will be displayed in the cell:


This indicates that there are 3 people living in New York in the given dataset.

Did you find this useful?