使用Query/ImportRange公式从多个工作表中导入数据,并返回ARRAYLITERAL错误 [英] Importing data from multiple sheets with Query/ImportRange formula returning ARRAYLITERAL ERROR

查看:452
本文介绍了使用Query/ImportRange公式从多个工作表中导入数据,并返回ARRAYLITERAL错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个Google表格,用于跟踪我们两个主要站点的班级出勤情况,并且表格上的每个标签都是不同的班级/课程.每张工作表都有一个数据"标签,可提取所有课程/课程数据.我正在尝试从这两张纸上提取数据表,并将它们放在第三张纸上,并通过程序(GED,CDP,ESL)整理类数据.我从一张工作表中提取数据没有问题,但是当我尝试堆叠QueryImportrange公式时,我不断收到 ARRAY LITERAL错误,该行缺少一行.

I have 2 Google Sheets which track class attendance for our two main sites and each tab on the sheet is a different class/course. Each sheet has a "data" tab which pulls all the class/course data. I am trying to pull the data sheets from these two sheets and put them on a 3rd sheet and organize the class data by a program (GED, CDP, ESL). I have had no issues pulling the data from one sheet, but when I tried stacking the Query and Importrange formulas, I keep receiving an ARRAY LITERAL error that there is a missing row.

我的原始公式是

={QUERY(IMPORTRANGE("1avE5TJIDVNL7_wqjDLPgocZuecr5Aoz7aI3cI5yIe34", "Data!A3:Ak1000"), "SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col26, Col27, Col28, Col29 WHERE Col3 CONTAINS 'ESL' AND Col7>0");QUERY(IMPORTRANGE("10q7kBUJVTw62p1cCZjUIR1CsFSev9Ik6q4K-X-RK40Y", "Data!A3:Ak1000"), "SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col26, Col27, Col28, Col29 WHERE Col3 CONTAINS 'ESL' AND Col7>0")}

并给出VALUE错误消息,提示ARRAY LITERAL缺少行.

and it gave a VALUE error message that the ARRAY LITERAL was missing rows.

根据其他站点的其他建议,我尝试了公式(如下),但是收到了公式解析错误消息,并尝试将大括号移动到ImportRange公式周围,但是继续收到公式解析错误消息

Based on other's recommendations from other sites, I tried the formula (below), but received a formula parse ERROR message and tried moving the curly brackets to just around the ImportRange formula, but continued to receive a formula parse ERROR MESSAGE

=QUERY{(IMPORTRANGE("1avE5TJIDVNL7_wqjDLPgocZuecr5Aoz7aI3cI5yIe34", "Data!A3:Ak1000");IMPORTRANGE("10q7kBUJVTw62p1cCZjUIR1CsFSev9Ik6q4K-X-RK40Y", "Data!A3:Ak1000")},"SELECT Col1, Col2, Col3, Col4, Col5, Col6, Col7, Col26, Col27, Col28, Col29 WHERE Col3 CONTAINS 'ESL' AND Col7>0")

我希望输出将列出Col3中包含"ESL"的所有类以及两个工作表中的相应列.

I expect that the output will list any classes that contain "ESL" in Col3 and the corresponding columns from both sheets.

推荐答案

了解 ARRAY_LITERAL错误:

如果两个查询都输出某些内容,那么一切都很好:

understanding ARRAY_LITERAL ERROR:

if both queries output something then all is good:

但是,如果其中一个查询没有任何要输出的内容,则会输出#N/A,但问题是#N/A仅位于第一个单元格中:

however if one of those queries doesn't have anything to output it outputs #N/A but the issue is that #N/A is only in the 1st cell:

但是数组期望两边的矩阵都相同(两个查询都有4列):

but array expects that matrix on both sides to be same (4 columns from both queries):

因此我们将每个查询都包装到IFERROR中,并在出现错误的情况下输出带有4个伪列的伪行- {"","","",""} -这将欺骗数组以使其输出:

so we wrap each query into IFERROR and in case of error we output fake row with 4 fake columns - {"","","",""} - which will trick the array to output it like:

因此请尝试这样:

=IFERROR(QUERY({IFERROR(QUERY(IMPORTRANGE(
  "1avE5TJIDVNL7_wqjDLPgocZuecr5Aoz7aI3cI5yIe34", "Data!A3:AK1000"), 
  "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col26,Col27,Col28,Col29 
   where Col3 contains 'ESL' 
   and Col7>0", 0), {"","","","","","","","","","",""});
  IFERROR(QUERY(IMPORTRANGE(
 "10q7kBUJVTw62p1cCZjUIR1CsFSev9Ik6q4K-X-RK40Y", "Data!A3:AK1000"), 
  "select Col1,Col2,Col3,Col4,Col5,Col6,Col7,Col26,Col27,Col28,Col29 
   where Col3 contains 'ESL'
   and Col7>0", 0), {"","","","","","","","","","",""})}, 
  "where Col1 is not null", 0))

这篇关于使用Query/ImportRange公式从多个工作表中导入数据,并返回ARRAYLITERAL错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆