I want to import a few spreadsheets into one with some criteria, unfortunately if one of the spreadsheets doesn't return any data, the ARRAYFORMULA
is asking for ARRAY_LITERAL
instead of empty result.
What do I need to use in the IFERROR
function so that ARRAYFORMULA
appends nothing and is happy to continue?
This is what I have now:
={
QUERY(IMPORTRANGE("<spreadsheet>", "Range!B2:J"), "SELECT Col1, Col2, Col3, Col5, Col9 WHERE Col1 <> '' AND Col5 >= 18 ");
IFERROR(QUERY(IMPORTRANGE("<spreadsheet2>", "Range!B2:K"), "SELECT Col1, Col3, Col2, Col4, Col6, Col10 WHERE Col10 <> '' AND Col6 >= 18"), "")
}
I wrapped the second one in IFERROR
but the empty string is not a valid ARRAY_LITERAL
, so what can I do instead of it?
Full error:
In ARRAY_LITERAL, an Array Literal was missing values for one or more rows.
I realised I could give it an empty row with the same number of columns like I1:N2
but you never know if you might need to use these columns and then the query would need to change.
I suggest using an empty array:
=iferror(query(..., ...), {"", "", "", ..., ""} )
Note:
Edit
by @Moseleyi.
Makes sense, but of course, it still produces empty rows, and if I wrap my ARRAYFORMULA in SORT, the empty rows will be shown first, but when I use empty cells they won't, probably because they're actually NULL. But I replaced empty strings with
IFERROR(1/0)
and it worked.