Search code examples
arraysgoogle-sheetsformattinggoogle-sheets-formulagoogle-query-language

How to convert an IMPORTRANGE() array to a string, for use with QUERY()?


I have the same problem which is discussed here, except that I am working with IMPORTRANGE() instead of a direct array reference (e.g., D12:I119). Somehow I need QUERY() to understand its input as an array of strings. But my attempt to addend a null string (&"") to IMPORTRANGE(), as suggested in the link, doesn't work:

QUERY(IMPORTRANGE("https://docs.google.com/spreadsheets/d/...","Sheet1!A3:1000")&"","select Col1, Col2")

How else can I get around this? Unfortunately, I can't change the data on the spreadsheet referenced by IMPORTRANGE().


Solution

  • use:

    =INDEX(QUERY(TO_TEXT(IMPORTRANGE("https://docs.google.com/spreadsheets/d/...", 
     "Sheet1!A3:1000")), 
     "select Col1, Col2", )