Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google sheets 将总行添加到堆叠的Google查询表_Google Sheets_Google Query Language - Fatal编程技术网

Google sheets 将总行添加到堆叠的Google查询表

Google sheets 将总行添加到堆叠的Google查询表,google-sheets,google-query-language,Google Sheets,Google Query Language,我有一个巨大但美丽的公式,它是由尊敬的Stackoverflow成员@player0巧妙制作的,效果非常好 我需要将总计行添加到3个生成的查询表中。因为我不完全理解这个公式,所以我在添加总行时遇到了困难。除了最后一个表,每个总计行将对列中的值求和,该表将取列中百分比的平均值 此外,如果特定年份的数据不可用,则会导致#值错误。如果数据不可用,我需要显示一些消息或一个空白,例如今年的数据不可用 这是一个具有编辑权限的文件 我计算了前两个表的总行数,但不知道在哪里插入,例如: {TRANSPO

我有一个巨大但美丽的公式,它是由尊敬的Stackoverflow成员@player0巧妙制作的,效果非常好

  • 我需要将总计行添加到3个生成的查询表中。因为我不完全理解这个公式,所以我在添加总行时遇到了困难。除了最后一个表,每个总计行将对列中的值求和,该表将取列中百分比的平均值

  • 此外,如果特定年份的数据不可用,则会导致#值错误。如果数据不可用,我需要显示一些消息或一个
    空白
    ,例如
    今年的数据不可用

这是一个具有编辑权限的文件

我计算了前两个表的总行数,但不知道在哪里插入,例如:

{TRANSPOSE(QUERY('Study Report'!$A:$T,"SELECT COUNT(B) WHERE YEAR(S) = "& $C$1 &" AND O != 'NO - all fine' AND L != 'Cancelled' GROUP BY S LABEL COUNT(B) 'TOTAL'",0))}

-----------编辑:------------

更新了
Clubbed Tables
下的公式,为
所有表添加
总计
。它在我的生产表中运行良好,但在FTR表格电子表格中不起作用<代码>唯一剩下的东西:

  • 对于数据可能不可用的特定年份,我如何删除
    #值
    错误并显示空白或其他文本
更新了公式,其中所有3个表都有其总计行:

=ARRAYFORMULA(IF(C1="", "select Year in C1", {TRANSPOSE(QUERY(TRANSPOSE(QUERY(IFNA(
 HLOOKUP(INDEX(TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null 
    and year(S)="&C1&" 
    and L!='Cancelled' 
    and O!='NO - all fine' 

  group by S 
  pivot N 
  label S 'NO OF ISSUES'")), 1), TRANSPOSE(QUERY({'Study Report'!$A:$T}, 
 "select Col19,count(Col2) 
  where Col19 is not null
    and year(Col19)="&C1&" 
    and Col12!='Cancelled' 
    and Col15 != 'NO - all fine' 
  group by Col19 
  pivot Col14 
  label Col19 'NO OF ISSUES'")), ROW(A:A), 0)), 
 "where Col1 <> '#REF!'")), 
 " format Col1 'yyyy-mmm'")); TRANSPOSE(QUERY('Study Report'!$A:$T,"SELECT COUNT(B) WHERE YEAR(S) = "& $C$1 &" AND O != 'NO - all fine' AND L != 'Cancelled' GROUP BY S LABEL COUNT(B) 'TOTAL'",0));
 SPLIT(REPT(" ♠", COLUMNS(TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null
    and year(S)="&C1&" 
    and L!='Cancelled' 
  group by S 
  pivot N 
  label S 'TOTAL OPPORTUNITIES'")))), "♠"); 
 TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null
    and year(S)="&C1&" 
    and L!='Cancelled' 
  group by S 
  pivot N 
  label S 'TOTAL OPPORTUNITIES'")); TRANSPOSE(QUERY('Study Report'!$A:$T,"SELECT COUNT(B) WHERE YEAR(S) = "& $C$1 &" AND L != 'Cancelled' GROUP BY S LABEL COUNT(B) 'TOTAL'",0));
 SPLIT(REPT(" ♠", COLUMNS(TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null
    and year(S)="&C1&" 
    and L!='Cancelled' 
  group by S 
  pivot N 
  label S 'TOTAL OPPORTUNITIES'")))), "♠"); 

 REGEXREPLACE(TO_TEXT(QUERY(QUERY({QUERY(
 {'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T, 'Study Report'!S1:S&
 IF('Study Report'!S1:S="",,"♥"&TEXT('Study Report'!S1:S, "yyyy-mmm"))}, 
 "select Col1,Col19,Col14,Col21,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14,Col21"),
 IFNA(VLOOKUP(INDEX(QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,Col19,Col14,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14"),,1), 
 QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' and Col15!= 'NO - all fine' group by Col1"), 2, 0))}, 
 "select Col4,Col3,Col6/Col5"), 
 "select Col2,max(Col3) group by Col2 pivot Col1 label Col2'FTR%' format max(Col3)'#.00%'")), "(\d+♥)", );

regexreplace(to_text(transpose(query(query(QUERY({QUERY(
 {'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T, 'Study Report'!S1:S&
 IF('Study Report'!S1:S="",,"♥"&TEXT('Study Report'!S1:S, "yyyy-mmm"))}, 
 "select Col1,Col19,Col14,Col21,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14,Col21"),
 IFNA(VLOOKUP(INDEX(QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,Col19,Col14,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14"),,1), 
 QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' and Col15!= 'NO - all fine' group by Col1"), 2, 0))}, 
 "select Col4,Col3,Col6/Col5"),"select Col1, avg(Col3) where Col1 is not null group by Col1 format avg(Col3) '0.00%'"),"Select Col2 label Col2 'TOTAL'"))),"(\d+♥)",)
}))
=ARRAYFORMULA(如果(C1=”,“在C1中选择年份”,{TRANSPOSE(查询(
HLOOKUP(索引(转置)查询(‘研究报告’!$A:$T,
“选择S,计数(B)
其中S不为空
年份=“&C1&”
而我!=“取消”
哦!=“不,一切都好”
按S分组
支点
标签S'NO OF ISSUES'),1),转置(查询({'Study Report'!$A:$T},
选择第19列,计数(第2列)
其中Col19不为null
年份(Col19)=“&C1&”
和Col12!=“取消”
还有Col15!=“不,一切都好”
Col19分组
枢轴轴14
标签Col19“问题数量”),第(A:A)行,0)),
“其中Col1'#REF!'”),
“格式Col1‘yyyy-mmm’”);转置(查询(‘研究报告’!$A:$T),“选择计数(B),其中年份=”&$C$1&“和O!=‘不-全部罚款’和L!=‘取消’按标签计数分组(B)‘总计’”,0));
拆分(报告)♠", 列(转置(查询(‘研究报告’!$A:$T、,
“选择S,计数(B)
其中S不为空
年份=“&C1&”
而我!=“取消”
按S分组
支点
标签S“总机会”(TOTAL OPPORTUNITIES)”,”♠"); 
转置(查询(‘研究报告’!$A:$T,
“选择S,计数(B)
其中S不为空
年份=“&C1&”
而我!=“取消”
按S分组
支点
标签S‘总机会’);转置(查询(‘研究报告’!$A:$T,“选择计数(B),其中年份=”&$C$1&“和L!=‘取消’分组,由标签计数(B)‘总计’”,0));
拆分(报告)♠,列(转置(查询(‘研究报告’!$A:$T,
“选择S,计数(B)
其中S不为空
年份=“&C1&”
而我!=“取消”
按S分组
支点
标签S“总机会”(TOTAL OPPORTUNITIES)”,”♠"); 
REGEXREPLACE(TO_TEXT)(查询({QUERY(
{“研究报告”!S1:S&“♦&‘研究报告’!N1:N,‘研究报告’!B1:T,‘研究报告’!S1:S&
如果('研究报告'!S1:S=“”,”♥文本('研究报告'!S1:S,“yyyy-mmm”)},
“选择Col1、Col19、Col14、Col21、count(Col2),其中Col19不为空,年份(Col19)=“&C1&”和Col12!=“取消”按Col1、Col19、Col14、Col21分组”),
IFNA(VLOOKUP(索引)查询({'Study Report'!S1:S&“♦“&‘研究报告’!N1:N,‘研究报告’!B1:T},
选择Col1、Col19、Col14、count(Col2),其中Col19不为空,年份(Col19)=“&C1&”和Col12!=“取消”按Col1、Col19、Col14分组”)、1),
查询({'Study Report'!S1:S&“♦“&‘研究报告’!N1:N,‘研究报告’!B1:T},
选择Col1,count(Col2),其中Col19不为空,年份(Col19)=“&C1&”和Col12!=“取消”和Col15!=“不-所有罚款”按Col1分组),2,0)),
“选择列4、列3、列6/列5”),
“按Col2轴选择Col2,max(Col3)分组Col1标签Col2'FTR%'格式max(Col3)#.00%”),”(\d+♥)", );
regexreplace(to_text)转置(transpose)查询(query)查询({query(
{“研究报告”!S1:S&“♦&‘研究报告’!N1:N,‘研究报告’!B1:T,‘研究报告’!S1:S&
如果('研究报告'!S1:S=“”,”♥文本('研究报告'!S1:S,“yyyy-mmm”)},
“选择Col1、Col19、Col14、Col21、count(Col2),其中Col19不为空,年份(Col19)=“&C1&”和Col12!=“取消”按Col1、Col19、Col14、Col21分组”),
IFNA(VLOOKUP(索引)查询({'Study Report'!S1:S&“♦“&‘研究报告’!N1:N,‘研究报告’!B1:T},
选择Col1、Col19、Col14、count(Col2),其中Col19不为空,年份(Col19)=“&C1&”和Col12!=“取消”按Col1、Col19、Col14分组”)、1),
查询({'Study Report'!S1:S&“♦“&‘研究报告’!N1:N,‘研究报告’!B1:T},
选择Col1,count(Col2),其中Col19不为空,年份(Col19)=“&C1&”和Col12!=“取消”和Col15!=“不-所有罚款”按Col1分组),2,0)),
“选择Col4,Col3,Col6/Col5”),“选择Col1,其中Col1不为空的平均值(Col3)(按Col1格式平均值(Col3)'0.00%'”,“选择Col2标签Col2'总计'),”(\d+♥)",)
}))

对不起,在我看到#REF-我的错误!之后我甚至没有阅读代码。我将在今天晚些时候再次查看此代码。对不起,在我看到#REF-我的错误!之后我甚至没有阅读代码。我将在今天晚些时候再次查看此代码。
=ARRAYFORMULA(IF(C1="", "select Year in C1", {TRANSPOSE(QUERY(TRANSPOSE(QUERY(IFNA(
 HLOOKUP(INDEX(TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null 
    and year(S)="&C1&" 
    and L!='Cancelled' 
    and O!='NO - all fine' 

  group by S 
  pivot N 
  label S 'NO OF ISSUES'")), 1), TRANSPOSE(QUERY({'Study Report'!$A:$T}, 
 "select Col19,count(Col2) 
  where Col19 is not null
    and year(Col19)="&C1&" 
    and Col12!='Cancelled' 
    and Col15 != 'NO - all fine' 
  group by Col19 
  pivot Col14 
  label Col19 'NO OF ISSUES'")), ROW(A:A), 0)), 
 "where Col1 <> '#REF!'")), 
 " format Col1 'yyyy-mmm'")); TRANSPOSE(QUERY('Study Report'!$A:$T,"SELECT COUNT(B) WHERE YEAR(S) = "& $C$1 &" AND O != 'NO - all fine' AND L != 'Cancelled' GROUP BY S LABEL COUNT(B) 'TOTAL'",0));
 SPLIT(REPT(" ♠", COLUMNS(TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null
    and year(S)="&C1&" 
    and L!='Cancelled' 
  group by S 
  pivot N 
  label S 'TOTAL OPPORTUNITIES'")))), "♠"); 
 TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null
    and year(S)="&C1&" 
    and L!='Cancelled' 
  group by S 
  pivot N 
  label S 'TOTAL OPPORTUNITIES'")); TRANSPOSE(QUERY('Study Report'!$A:$T,"SELECT COUNT(B) WHERE YEAR(S) = "& $C$1 &" AND L != 'Cancelled' GROUP BY S LABEL COUNT(B) 'TOTAL'",0));
 SPLIT(REPT(" ♠", COLUMNS(TRANSPOSE(QUERY('Study Report'!$A:$T, 
 "select S,count(B) 
  where S is not null
    and year(S)="&C1&" 
    and L!='Cancelled' 
  group by S 
  pivot N 
  label S 'TOTAL OPPORTUNITIES'")))), "♠"); 

 REGEXREPLACE(TO_TEXT(QUERY(QUERY({QUERY(
 {'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T, 'Study Report'!S1:S&
 IF('Study Report'!S1:S="",,"♥"&TEXT('Study Report'!S1:S, "yyyy-mmm"))}, 
 "select Col1,Col19,Col14,Col21,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14,Col21"),
 IFNA(VLOOKUP(INDEX(QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,Col19,Col14,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14"),,1), 
 QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' and Col15!= 'NO - all fine' group by Col1"), 2, 0))}, 
 "select Col4,Col3,Col6/Col5"), 
 "select Col2,max(Col3) group by Col2 pivot Col1 label Col2'FTR%' format max(Col3)'#.00%'")), "(\d+♥)", );

regexreplace(to_text(transpose(query(query(QUERY({QUERY(
 {'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T, 'Study Report'!S1:S&
 IF('Study Report'!S1:S="",,"♥"&TEXT('Study Report'!S1:S, "yyyy-mmm"))}, 
 "select Col1,Col19,Col14,Col21,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14,Col21"),
 IFNA(VLOOKUP(INDEX(QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,Col19,Col14,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' group by Col1,Col19,Col14"),,1), 
 QUERY({'Study Report'!S1:S&"♦"&'Study Report'!N1:N, 'Study Report'!B1:T}, 
 "select Col1,count(Col2) where Col19 is not null and year(Col19)="&C1&" and Col12 != 'Cancelled' and Col15!= 'NO - all fine' group by Col1"), 2, 0))}, 
 "select Col4,Col3,Col6/Col5"),"select Col1, avg(Col3) where Col1 is not null group by Col1 format avg(Col3) '0.00%'"),"Select Col2 label Col2 'TOTAL'"))),"(\d+♥)",)
}))