为什么我的 IFS 函数不能与 QUERY 一起使用?

Why my IFS function is not working with QUERY?

当我使用 IF 时,它工作得很好。

=IF(H6="Vaga", QUERY(A2:D60, "SELECT * WHERE A "&H3&" 
"&H9&"'"),QUERY(A2:D60, "SELECT * WHERE C "&H3&" '"&H9&"'"))

但是当我尝试IFS时,它说行数和列数有误

=IFS(H6="Vaga", QUERY(A2:D60, "SELECT * WHERE A "&H3&" '"&H9&"'"), 
H6="Empresa", QUERY(A2:D60, "SELECT * WHERE C "&H3&" '"&H9&"'"), 
H6="Postada", QUERY(A2:D60, "SELECT * WHERE E "&H3&" '"&H9&"'"))

我不知道为什么它不起作用,但是 IFS 对数组有一些限制,可能对 query 也有限制。但是,您的公式的一个简单解决方案似乎只是推断出多个 if 语句:

=IF(H6="Vaga", QUERY(A2:D60, "SELECT * WHERE A "&H3&" '"&H9&"'"),
  if(H6="Empresa", QUERY(A2:D60, "SELECT * WHERE C "&H3&" '"&H9&"'"),
  If(H6="Postada", QUERY(A2:D60, "SELECT * WHERE E "&H3&" '"&H9&"'"),"nothing")))

尝试:

=QUERY(A2:D60, "where "&
 CHOOSE(MATCH(H6, {"Vaga","Empresa","Postada"}, ), "A","C","E")&H3&" '"&H9&"'")

参见:https://webapps.stackexchange.com/a/124685/186471