Google Sheets – Using Formulas in Query Function

google sheetsgoogle-sheets-query

What has been tried so far :

=query(dataset, "select Col1 where Col1='"&left(C1,3)&"' and Col2 is not null")

What I am trying to do :

=query(dataset, "select "&left(&"Col1"&,3)&" where Col1='"&left(C1,3)&"' and Col2 is not null")

I am trying to find display only first 3 letters of returned Column. I might want to use other formulas too. Is it a possibility in Google Sheets Query?

Best Answer

EDIT: (following OP's request)

You can use (replacing C2:C10 with your corresponding column) the following:

=QUERY({ArrayFormula(LEFT(C2:C10,3)),dataset}, "select Col1, Col3 where  Col4 is not null")

Original answer

Try this formula instead:

=ArrayFormula(LEFT(QUERY(dataset, "select Col1 where Col2 is not null"),3))

You don't have to put the function LEFT inside the QUERY.