我在查询中遇到OR逻辑问题。我试图在列(D)中加总,如果:
•A列= cars/build-price/carselector.html
•列B =包含ateca
或ibiza
(单元格可能是“获取ateca”,“新ibiza xx”,...)
•C列= footer
首先尝试使用SUMIFS但不起作用:
=SUMIFS(C:C;A:A;"cars/build-price/carselector.html";B:B;{"ateca"; "ibiza"};D:D;"footer")
然后尝试使用QUERY,但我真的不懂这种语言:
=SUM(QUERY(A:D;"Select C where A='cars/build-price/carselector.html' and D='footer' and (B='ateca' or B='ibiza')"))
找不到如何拟合“包含”和“或”逻辑。
有人可以帮忙吗?
答案 0 :(得分:3)
查询可以是:
=QUERY(A:D,"select sum(D) where A='cars/build-price/carselector.html' and C='footer' and (B contains 'ateca' or B contains 'ibiza')")
答案 1 :(得分:1)
试试这个公式:
=SUMPRODUCT(C:C,ArrayFormula((A:A="cars/build-price/carselector.html")*(D:D="footer")*((N(REGEXMATCH(B:B,"ateca")))+(N(REGEXMATCH(B:B,"ibiza"))))))