How to apply multiple criteria when using VLOOKUP+QUERY+IMPORTRANGE?

So, right now, the formula below successfully queries data from another file, butthis based on a column’s data as the criteria. The need is to have more than one criteria and I’m not sure if thecolumn to be compared against needs to come in as an additional query, together with the first query…so I’m lost here.

This is the formula I’m using:

=Arrayformula(
   if(F9:F="";"";
      vlookup(A9:A;
         QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/xxxxXXXXXXXxxxxxXXXX/edit";"Costura!A1:R"); 
         "select Col6, Col8, Col14";0)
      ;2;0)
    )
 )

Here’s a sample file with dummy data!

>Solution :

can be done like this:

=ARRAYFORMULA(IF(B6:B="",,IFNA(VLOOKUP(A6:A&B6:B, 
 {QUERY(Data!A1:J, "select A", 0)&
  QUERY(Data!A1:J, "select H", 0), 
  QUERY(Data!A1:J, "select J", 0)}, 2, 0))))

which will translate into this:

=ARRAYFORMULA(IF(B6:B="",,IFNA(VLOOKUP(A6:A&B6:B, 
 {IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data!A:A")&
  IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data!H:H"), 
  IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data!J:J")}, 2, 0))))

enter image description here

Leave a Reply