Search code examples
google-sheetsgoogle-sheets-formulagoogle-query-language

Google Sheets With OR in Query


I am using OR criteria in query to exclude data with specific text but it seems that OR criteria is not working. Check The below image in which I used the query function to exclude data where Column B is 'West' or 'East' but the its not working.

Click To See The Image

Any help on above will be appreciated.

Formula used:-

=QUERY(A1:B14,"Select * Where A is not null and (B<>'West' or B<>'East')")

Solution

  • A1 is not null, B1 is not "East". Both are true for C1. You're looking for and. See De Morgan's law: When you negate, you use and.

    =QUERY(A1:B14,"Select * Where A is not null and B<>'West' and B<>'East'")
    

    Or

    =QUERY(A1:B14,"Select * Where A is not null and not (B='West' or B='East')")