Search code examples
google-sheetsgoogle-query-language

OR logic and CONTAINS in a query in Google Sheets


I have a problem with an OR logic in a query. I'm trying to make a sum of a column (D), if:

• column A = cars/build-price/carselector.html

• column B = contains ateca or ibiza (the cell could be "get the ateca", "new ibiza xx", ...)

• column C = footer

First tried with a SUMIFS but didn't work:

=SUMIFS(C:C;A:A;"cars/build-price/carselector.html";B:B;{"ateca"; "ibiza"};D:D;"footer")

then tried with a QUERY, but I don't really know this language:

=SUM(QUERY(A:D;"Select C where A='cars/build-price/carselector.html' and D='footer' and (B='ateca' or B='ibiza')"))

Can't find how to fit the "contains" and the "or" logic.

Someone can help?


Solution

  • A query could be:

    =QUERY(A:D,"select sum(D) where A='cars/build-price/carselector.html' and C='footer' and (B contains 'ateca' or B contains 'ibiza')")