QUERY错误:“在ARRAY_LITERAL中,数组文字缺少一个或多个行的值”

时间:2019-07-20 09:44:43

标签: regex google-sheets google-sheets-formula array-formulas google-sheets-query

希望有人可以帮助我!

我正在从大型收入预测表中提取数据,并将其汇总到几个单独的(更整齐的)表中,以便为主要预测中的每个客户提供从1月到12月的预测表。

输出数据将包含:

客户A

A列:项目名称

B列:收入状态

C列:Jan值

D列开始:2月至12月的值

原始数据源(C列)中的收入状态为“已签约”,“拟议”,“已识别”和“查找”。客户A仅具有“合同规定的收入”和“要查找的收入”,因此我建立的数组公式给出了一个错误,因为它无法找到建议和确定的数据。

源数据

此处链接: LINK

G列是项目名称,C列是收入状态,L-W列是1月到12月。

这是我的公式(仅缩短了2种收入状态,共有4种)。我应该补充一点,我正在尝试自定义对“收入状态”的排序,以确保预测数字的安全性。

={QUERY('2019_MRS Data'!A:W,"select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) where (E='"&A2&"') AND C='Contracted'GROUP BY C,G ORDER BY C label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)'' ",1);QUERY('2019_MRS Data'!A:W,"select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) where (E='"&A2&"') AND C='Proposal'GROUP BY C,G ORDER BY C label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)'' ",1)}

1 个答案:

答案 0 :(得分:1)

您可以像这样在查询中使用正则表达式:

=QUERY('2019_MRS Data'!A:W,
 "select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) 
  where E='"&A2&"' 
    and C matches 'Contracted|Proposal|Identified|To Find'
  group by C,G 
  order by C 
  label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)''", 1)

0

ARRAY_LITERAL ERROR explained


更新:

=QUERY({IFERROR(QUERY('2019_MRS Data'!A:W,
 "select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) 
  where E='"&A2&"' 
    and C matches 'Contracted'
  group by C,G 
  order by C 
  label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)''", 0),
 {"","","","","","","","","","","","","",""});
 IFERROR(QUERY('2019_MRS Data'!A:W,
 "select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) 
  where E='"&A2&"' 
    and C matches 'Proposal'
  group by C,G 
  order by C 
  label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)''", 0),
 {"","","","","","","","","","","","","",""});
 IFERROR(QUERY('2019_MRS Data'!A:W,
 "select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) 
  where E='"&A2&"' 
    and C matches 'Anticipated'
  group by C,G 
  order by C 
  label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)''", 0),
 {"","","","","","","","","","","","","",""});
 IFERROR(QUERY('2019_MRS Data'!A:W,
 "select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) 
  where E='"&A2&"' 
    and C matches 'CIBS'
  group by C,G 
  order by C 
  label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)''", 0),
 {"","","","","","","","","","","","","",""});
 IFERROR(QUERY('2019_MRS Data'!A:W,
 "select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) 
  where E='"&A2&"' 
    and C matches 'UBS'
  group by C,G 
  order by C 
  label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)''", 0), 
 {"","","","","","","","","","","","","",""});
 IFERROR(QUERY('2019_MRS Data'!A:W,
 "select G,C,sum(L),sum(M),sum(N),sum(O),sum(P),sum(Q),sum(R),sum(S),sum(T),sum(U),sum(V),sum(W) 
  where E='"&A2&"' 
    and C matches 'Missed'
  group by C,G 
  order by C 
  label sum(L)'',sum(M)'',sum(N)'',sum(O)'',sum(P)'',sum(Q)'',sum(R)'',sum(S)'',sum(T)'',sum(U)'',sum(V)'',sum(W)''", 0),
 {"","","","","","","","","","","","","",""})}, "where Col1 is not null", 0)