我当前正在使用此查询
=sort({IFERROR(query('PI Calcs'!C4:K51,"select C,G,H, K where C is not null and G > 0"),{"","","",""});IFERROR(query('PI Calcs'!C54:P101,"select C,J,K,P where C is not null and J > 0"),{"","","",""});IFERROR(query('PI Calcs'!C104:P127,"select C,J,K,P where C is not null and J > 0"),{"","","",""})},2,false)
我通过使用QUERY将3个范围合并在一起。我正在使用IFERROR,因为如果任何查询返回空集,那么我将无法将它们合并在一起,失败结果将是4个值的空行。
我的困难是从最终集中删除那些空值,因为对它们进行排序时,每个失败的查询都会得到1个空行。我尝试使用FILTER,但由于它是动态创建的,因此无法引用该范围中的列。
如何将空白行过滤出动态创建的范围之外? 有没有一种方法可以查询和合并结果,而又不会回到空范围内?
答案 0 :(得分:1)
尝试较短的一个:
=QUERY(SORT({IFERROR(QUERY('PI Calcs'!C4:K51,
"select C,G,H,K
where C is not null
and G > 0"), {"","","",""});
IFERROR(QUERY({'PI Calcs'!C54:P101; 'PI Calcs'!C104:P127},
"select Col1,Col8,Col9,Col14
where Col1 is not null
and Col8 > 0"), {"","","",""}), 2, 0),
"where Col1 is not null", 0)
或更短:
=QUERY({'PI Calcs'!C54:P101; 'PI Calcs'!C104:P127;
{'PI Calcs'!C4:I51, 'PI Calcs'!G4:L51,'PI Calcs'!K4:K51}},
"select Col1,Col8,Col9,Col14
where Col1 is not null
and Col8 > 0
order by Col2 desc", 0)
答案 1 :(得分:0)
为什么不查询您的查询?
=QUERY({IFERROR(query('PI Calcs'!C4:K51,"select C,G,H, K where C is not null and G > 0"),{"","","",""});IFERROR(query('PI Calcs'!C54:P101,"select C,J,K,P where C is not null and J > 0"),{"","","",""});IFERROR(query('PI Calcs'!C104:P127,"select C,J,K,P where C is not null and J > 0"),{"","","",""})},"where Col1 is not null order by Col2 desc",0)