google-sheetsimportgoogle-sheets-formulaformulagoogle-query-language

How to use VLOOKUP() + QUERY() + IMPORTRANGE() with multiple conditions?


I currently have this one working fine with 01 condition, but I can't manage to include another criteria:

=Arrayformula(if(A3:A="","",IFNA(vlookup(E3:E,QUERY(IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU","Arrayformula VLOOKUP multiple columns!A1:C"), "select Col1, Col2, Col3 label Col3 'Qtd'",0),3,0))))

I've started by concatenating A3:A&E3:E, but I don't know how to get the data ranges for comparison in this fashion using QUERY().

Here is the result VS expectation:

enter image description here

Also, here is an example for tests: https://docs.google.com/spreadsheets/d/1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU/edit?usp=sharing


Solution

  • use:

    =ARRAYFORMULA(IF(A3:A="",,IFNA(VLOOKUP(E3:E&" "&F3:F,
     QUERY({FLATTEN(QUERY(TRANSPOSE(
     IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Arrayformula VLOOKUP multiple columns!A1:B")),,9^9)),
     IMPORTRANGE("1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Arrayformula VLOOKUP multiple columns!C1:C")}, 
     "select Col1,Col2 label Col2 'x'", 0), 2, 0))))
    

    enter image description here