Chinbin
Chinbin

Reputation: 253

How to use where query in Google Spreadsheet with filter multiple conditions

I have some of the scenario for the google sheets filtering and brings the data to another sheets. Having some issue on combining with multiple AND when using "Where". It does not show result after apply for the syntax. I was wondering how if we want to filtering more than 1, maybe have 2,3,4,5 data to filter. How do we really make it in the query GoogleSheets, please help me to have more clearer understanding on the "where" query with multiple conditions. Thank you so much!

Here is the link of the google sheets

https://docs.google.com/spreadsheets/d/1RNku0Bpj-hbBkKcfGjfJ_CU9gQbWAz6MxGAlK5oGOl0/edit?usp=sharing

Scenario1: Get date in September(B)

Scenario2: Get the data that's show Green, Red(A)

Scenario3: Get the date that filling in billed date(D) also is September

enter image description here

The formula that I'm trying to apply is failed to run....

=QUERY(A:D, "select SUM(C) WHERE B >= DATE'2021-09-01' AND B<=Date'2021-09-30'AND A='Blue' AND A='Green' AND ISDATE(D) ")

Upvotes: 1

Views: 1469

Answers (2)

Mike Steelson
Mike Steelson

Reputation: 15308

A can't be at the same time Blue and Green. So try

=QUERY(A:D, "select SUM(C) WHERE B >= DATE'2021-09-01' AND B<=Date'2021-09-30' AND (A='Blue' OR A='Green' OR A='Red') and D>=DATE'2021-09-01' AND D<=Date'2021-09-30' ")

enter image description here

Upvotes: 2

AsiaBoba
AsiaBoba

Reputation: 1

=FILTER(A2:D,MONTH(B2:B)=9,REGEXMATCH(A2:A,"Red|Green"),MONTH(D2:D)=9)

Upvotes: 0

Related Questions