在第二个参数中将Query
函数与text()
或To_text()
函数一起使用对我来说完全正常,如以下示例所示:
=QUERY({June2019!$M$3:$Z;July2019!$M$3:$Z;August2019!$M$3:$Z},"select
SUM(Col5) where Col1 > "&text((Column()-2)*5,"#")&" and Col1 <=
"&text((Column()-1)*5,"#")&" label SUM(Col5) ''")
但是,一旦我以更复杂的方式使用此查询功能,就会收到以下两个错误之一:
=IF((ISBLANK(B27:27)=False),
(QUERY({June2019!$M$3:$Z;July2019!$M$3:$Z;August2019!$M$3:$Z},"select
SUM(Col5) where (Col1 > "&text((Column()-2)*5,"#")&") and (Col1 <=
"&text((Column()-1)*5,"#")&") label SUM(Col5)
''"))/(QUERY({June2019!$M$3:$Z;July2019!$M$3:$Z;August2019!$M$3:$Z},"select
COUNT(Col5) where (Col1 > "&text((Column()-2)*5,"#")&") and (Col1 <=
"&text((Column()-1)*5,"#")&") label COUNT(Col5) ''")),)
错误: 查询完成,输出为空。
错误: 无法解析函数QUERY参数2的查询字符串:PARSE_ERROR:在第1行第24列遇到““ Col1”“。期望其中之一:”(“ ...”(“ ...
任何帮助将不胜感激
答案 0 :(得分:1)
尝试:
=ARRAYFORMULA(IF(ISBLANK(B27:27)=FALSE,
QUERY({June2019!$M$3:$Z; July2019!$M$3:$Z; August2019!$M$3:$Z},
"select SUM(Col5)
where Col1 > "&(COLUMN()-2)*5&"
and Col1 <= "&(COLUMN()-1)*5&"
label SUM(Col5)''")/
QUERY({June2019!$M$3:$Z; July2019!$M$3:$Z; August2019!$M$3:$Z},
"select COUNT(Col5)
where Col1 > "&(COLUMN()-2)*5&"
and Col1 <= "&(COLUMN()-1)*5&"
label COUNT(Col5)''"), ))
或:
=ARRAYFORMULA(IF(ISBLANK(B27:27)=FALSE,
QUERY({June2019!$M$3:$Z; July2019!$M$3:$Z; August2019!$M$3:$Z},
"select avg(Col5)
where Col1 > "&(COLUMN()-2)*5&"
and Col1 <= "&(COLUMN()-1)*5&"
label avg(Col5)''"), ))