Google-sheets – How to concatenate string in select clause of a google sheet query

google sheetsgoogle-sheets-query

How can I concatenate a string in a select clause of google sheet query function ?

ex: =QUERY(DATAS!B:F; "SELECT B,C,D,'=image('&E&')',F WHERE upper(F) "&J4&" upper('"&N4&"') LIMIT 50";1)

Here I want to get E column as =image(E) in the sheet.

Anyone with an idea ?

Thanks :d

Best Answer

Idea is to wrap your query with another one to get URLs of images and use ARRAYFORMULA(IMAGE()) on output.

={
QUERY(
   QUERY(DATAS!B:F; "SELECT B,C,D,E,F WHERE upper(F) "&J4&" upper('"&N4&"') LIMIT 50";1);
   "SELECT COL1, COL2, COL3"),
ARRAYFORMULA(IMAGE(QUERY(
   QUERY(DATAS!B:F; "SELECT B,C,D,E,F WHERE upper(F) "&J4&" upper('"&N4&"') LIMIT 50";1);
   "SELECT COL4"))),
QUERY(
   QUERY(DATAS!B:F; "SELECT B,C,D,E,F WHERE upper(F) "&J4&" upper('"&N4&"') LIMIT 50";1);
   "SELECT COL1, COL2, COL4")
}