Home > Blockchain >  Why my IFS function is not working with QUERY?
Why my IFS function is not working with QUERY?

Time:11-25

When I use IF it works perfectly.

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

But when I try IFS, it says there is an error with number of rows and columns

=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&"'"))

CodePudding user response:

I don't know why it's not working, but IFS has some limitations with arrays and likely with query. However an easy solution to your formula would seem to be just to extrapolate out multiple if statements:

=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")))

CodePudding user response:

try:

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

see: https://webapps.stackexchange.com/a/124685/186471

  • Related