[英]How to find the highest N values in each group in Google Sheets
I want to use a formula to find the highest N values in each group in a Google Spread Sheets.我想使用一个公式来查找 Google 电子表格中每个组中的最高 N 值。
I tried this formula from infoinspired.com (credit to Prashanth):我尝试了infoinspired.com中的这个公式(感谢 Prashanth):
=ArrayFormula(QUERY({SORT(A2:B;1;true;2;false);IFERROR(row(A2:A)-match(query(SORT(A2:B;1;true;2;false);"Select Col1");query(SORT(A2:B;1;true;2;false);"Select Col1");0))};"Select Col1,Col2 where Col3<3")) =ArrayFormula(QUERY({SORT(A2:B;1;true;2;false);IFERROR(行(A2:A)-匹配(查询(SORT(A2:B;1;true;2;false);"选择 Col1");query(SORT(A2:B;1;true;2;false);"选择 Col1");0))};"选择 Col1,Col2 where Col3<3"))
But all it return is an Array_Literal error:但它返回的只是一个 Array_Literal 错误:
This is what I expect:这就是我的期望:
What is wrong with it?它有什么问题?
You have to put a comma, not a semi colon before IFERROR.您必须在 IFERROR 之前放置逗号,而不是分号。 It's creating two columns, one twice larger than the other instead of three columns;)它创建了两列,一列比另一列大两倍,而不是三列;)
=ArrayFormula(QUERY({SORT(A2:B,1,true,2,false),IFERROR(row(A2:A)-match(query(SORT(A2:B,1,true,2,false),"Select Col1"),query(SORT(A2:B,1,true,2,false),"Select Col1"),0))},"Select Col1,Col2 where Col3<3"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.