简体   繁体   English

ArrayFormula + 多个 IMPORTRANGE + QUERY

[英]ArrayFormula + multiple IMPORTRANGE + QUERY

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.我想将一些电子表格导入到一个具有某些条件的电子表格中,不幸的是,如果其中一个电子表格没有返回任何数据,则ARRAYFORMULA要求ARRAY_LITERAL而不是空结果。

What do I need to use in the IFERROR function so that ARRAYFORMULA appends nothing and is happy to continue?我需要在IFERROR函数中使用什么,以便ARRAYFORMULA附加任何内容并且很乐意继续?

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?我将第二个包裹在IFERROR但空字符串不是有效的ARRAY_LITERAL ,那么我该怎么办呢?

Full error:完整错误:

In ARRAY_LITERAL, an Array Literal was missing values for one or more rows.在 ARRAY_LITERAL 中,数组文字缺少一行或多行的值。

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.我意识到我可以给它一个空行,列数与I1:N2相同,但您永远不知道是否可能需要使用这些列,然后查询需要更改。

I suggest using an empty array :我建议使用空数组

=iferror(query(..., ...), {"", "", "", ..., ""} )

Note:笔记:

  • you select 6 columns, thus repeat "" six times.您选择 6 列,因此重复 "" 六次。

Edit编辑

by @Moseleyi.来自@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.有道理,但当然,它仍然会产生空行,如果我将 ARRAYFORMULA 包装在 SORT 中,空行将首先显示,但当我使用空单元格时,它们不会显示,可能是因为它们实际上是 NULL。 But I replaced empty strings with IFERROR(1/0) and it worked.但是我用IFERROR(1/0)替换了空字符串并且它起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM