1

I am unable to figure out how could we use formula within query results. I did not find any solution yet.

Like:

=query(sheet1!A1:Z,"Select A,B,Vlookup(D,sheet1!A1:A,1,false)");
TheMaster
  • 45,448
  • 6
  • 62
  • 85
Zamir
  • 217
  • 2
  • 11

2 Answers2

1
  1. If your range is A1:Z, the column where you can insert the formula without error must be bigger than Z
  2. Sheet formulas do not expect (nor allow) semicola at the end
  3. If D is a string, it should be nested in double quotes
  4. To combine your formulas, you need to combine the quotes correctly, e.g.:
=query(Sheet1!A1:Z, CONCATENATE("select A,B,",Vlookup("D",Sheet1!A1:A,1,false)))
ziganotschka
  • 25,866
  • 2
  • 16
  • 33
1

you can't. you need to do:

=ARRAYFORMULA({sheet1!A:B, IFNA(VLOOKUP(D:D, sheet1!A:A, 1, 0))})

and then you can play with query:

=ARRAYFORMULA(QUERY({sheet1!A:B, IFNA(VLOOKUP(D:D, sheet1!A:A, 1, 0))}, "select Col1,Col2,Col3", 0)
player0
  • 124,011
  • 12
  • 67
  • 124