How to Use Query Function in Google Sheets with Multiple Criteria

In Google Sheets, data can be filtered based on various criteria using the QUERY function. The WHERE keyword in the QUERY function allows data filtering using multiple criteria. There are three logical operators, namely AND, OR, and NOT, which can be used to combine these criteria.

For example, if there is a sheet containing employee names in one column A, the total sales in another column B, and the corresponding month of those sales in a third column C, the QUERY function can be applied to extract specific data from this sheet.
 

Sample data

To accomplish this, rules like “Filtering employees with sales exceeding $100 in January” or “Retrieving a list of employees with sales in either February OR March” can be established. The QUERY function enables the retrieval of this information by applying these rules.

Therefore, Google Sheets’ QUERY function permits data filtering in various ways by employing multiple criteria.

1) Logical Operator AND

The Logical Operator AND needs two conditions to be true for a row to show in the result. For instance, if somebody wants a list of workers who both sold a certain amount and are a particular worker, like John, the QUERY function would appear as follows:

=QUERY(A:C, "SELECT * WHERE A='Charlie' AND B<1000")

To include a row using this operator, both the conditions in the “WHERE” clause must be fulfilled.

Take a look at the result, you won’t find Charlie’s April sales. Although the first condition was valid and fulfilled the second condition (sales do not exceed 1000) wasn’t fulfilled. Consequently, since both conditions weren’t satisfied, April sales weren’t included in the result.

Logical Operator AND

Note: If the criteria only require one condition to be met, then logical operator OR should be considered.

2) Logical Operator OR

The OR operator requires any one of two conditions to be true. For example, if somebody wants a list that includes employees with the name Charlie or Nishi, then the formula given below will be used.

=QUERY(A:C, "SELECT * WHERE A='Charlie' OR A='Nishi'")

Using this QUERY will give the result as shown below:

Result of logical operator OR

To include a row using this operator only one condition needs to be fulfilled on either side of the condition in the WHERE clause.

Note: If all criteria require excluding certain rows based on a condition, then the NOT logical operator should be used.

3) Logical Operator NOT

The logical operator NOT excludes rows that meet a specific condition. For example, in the given sales data list that we used above, one can use the NOT operator to find staff who didn’t sell over 1,000 in May. This will help in identifying underperforming staff.

The NOT operator can be used in a QUERY as:

=QUERY(A:C, "SELECT * WHERE NOT B > 1000 AND C='May'")

This QUERY will give a list of employee names who did not make sales more than 1000 in the month of May. The result of this QUERY is shown below.
 

Result of Logical Operator NOT

How to Organize Google Form Responses with Query Functions

Organizing responses from Google Forms can be challenging, especially when dealing with large datasets. Leveraging the power of query functions in Google Sheets can streamline this process, allowing you to filter, sort, and analyze data efficiently.

Here, we’ll see how to organize Google Form responses with query functions, ensuring you can manage and interpret your data with ease. Also, we’ll see how to effortlessly organize your information, making it more accessible and valuable in google form.

Similar Reads

What is the Query Function of Google Sheets?

The QUERY function available, in Google Sheets is a tool for analyzing data. It allows users to extract information from tables using SQL syntax. This feature comes in handy when you need to filter, sort, and aggregate data especially when dealing with datasets. It also enables users to generate custom reports within Google Sheets....

How to Create a Google Sheet from your Google Form Responses

Step 1: Create a Google Form...

How to Use QUERY Function in Google Sheets to Collect Your Google Form Responses

The QUERY function in Google Sheets is a useful tool that helps you retrieve, filter, and organize information from a specific range within your spreadsheet data....

How to Use Query Function in Google Sheets with Multiple Criteria

In Google Sheets, data can be filtered based on various criteria using the QUERY function. The WHERE keyword in the QUERY function allows data filtering using multiple criteria. There are three logical operators, namely AND, OR, and NOT, which can be used to combine these criteria....

How to Use Parentheses to Combine Multiple Criteria

Parentheses in logical operators are used to control the order of evaluating conditions, ensuring that specific conditions are assessed first, which can impact the final outcome of a logical expression....

How to Use Cell Reference in Google Sheet Query

In Google Sheets Query, using cell references for specifying conditions is possible. Conditions can be directly input into the Query formula or placed in a cell for reference. This method allows for dynamic queries. However, it’s essential to remember that the Query’s SELECT, PIVOT, and GROUP BY clauses don’t use cell references but rather column identifiers like A, B, or Col1, Col2, etc. This distinction is important to avoid confusion when using cell references in the WHERE clause of the Query....

Benefits of Using Query Function in Google Sheets

Using the QUERY function in Google Sheets has several advantages:...

Conclusion

In conclusion, utilizing query functions in Google Sheets to organize responses from Google Forms is a powerful technique for managing large datasets efficiently. The advantages of utilizing this function are numerous including simplified data extraction, customization through filtering and sorting options, time efficiency, comprehensive data summarization, and streamlined reporting capabilities. Familiarizing oneself with keywords such, as SELECT, WHERE, ORDER BY and LIMIT will ensure the tailoring of data retrieval and analysis...

How to Organize Google Form Responses – FAQs

How to organize responses in Google Forms?...

Contact Us