我无法在RANK
内的分组行中使用ARRAYFORMULA
。
我有一个大数据集(约10万行),我想在其中创建一个ARRAYFORMULA
,使共享相同标识符的行具有不同的RANK
。
尽管我得到的结果没有拖拽公式(结合RANK
和FILTER
的问题),但是我无法用ARRAYFORMULA
复制结果。 This file with dummy data重现了问题。
预先,非常感谢您的帮助。
答案 0 :(得分:1)
原则上,您可以使用排序和计数来完成此操作,但是在实践中却很难,因为您想使用的函数(例如Countifs)不是数组友好的。这是一种比较漫长的方式,您可以在其中进行排序,对Slug和Points组合使用Vlookup,获取匹配的行号,然后从刚与Slug匹配的Vlookup中减去行号:
=ArrayFormula(if(A2:A<>"",vlookup(A2:A&"|"&B2:B,{sort(A2:A&"|"&B2:B,A2:A,true,B2:B,false),row(A2:A)},2,false)-
vlookup(A2:A,{sort(A2:A,A2:A,true),row(A2:A)},2,false)+1,""))
答案 1 :(得分:0)
也是解决方案:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&"♥"&B2:B, SORT(SPLIT(TRANSPOSE(SPLIT(
QUERY(TRANSPOSE(QUERY(TRANSPOSE("♦"&UNIQUE(SORT(FILTER(A2:A, A2:A<>"")))&"♥"&
SPLIT(TRANSPOSE(QUERY(TRANSPOSE(IF(QUERY(QUERY({A2:A, B2:B+(ROW(B2:B)*0.00000001)},
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"), "offset 1", 0)=1,
ROUNDDOWN(QUERY(QUERY({A2:A, B2:B+(ROW(B2:B)*0.00000001)},
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"), "limit 0", 1), 0), ))
,,999^99)), " ")&"♠"&transpose(SORT(ROW(INDIRECT("A1:A"&COLUMNS(SPLIT(TRANSPOSE(
QUERY(TRANSPOSE(IF(QUERY(QUERY({A2:A, B2:B+(ROW(B2:B)*0.00000001)},
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"), "offset 1", 0)=1,
ROUNDDOWN(QUERY(QUERY({A2:A, B2:B+(ROW(B2:B)*0.00000001)},
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"), "limit 0", 1), 0), ))
,,999^99)), " ")))), 1, 0))),,999^99)),,999^99), "♦")), "♠"), 2, 1), 2, 0)))
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A&"♥"&B2:B; SORT(SPLIT(TRANSPOSE(SPLIT(
QUERY(TRANSPOSE(QUERY(TRANSPOSE("♦"&UNIQUE(SORT(FILTER(A2:A; A2:A<>"")))&"♥"&
SPLIT(TRANSPOSE(QUERY(TRANSPOSE(IF(QUERY(QUERY({A2:A\ B2:B+(ROW(B2:B)*0,00000001)};
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"); "offset 1"; 0)=1;
ROUNDDOWN(QUERY(QUERY({A2:A\ B2:B+(ROW(B2:B)*0,00000001)};
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"); "limit 0"; 1); 0); ))
;;999^99)); " ")&"♠"&transpose(SORT(ROW(INDIRECT("A1:A"&COLUMNS(SPLIT(TRANSPOSE(
QUERY(TRANSPOSE(IF(QUERY(QUERY({A2:A\ B2:B+(ROW(B2:B)*0,00000001)};
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"); "offset 1"; 0)=1;
ROUNDDOWN(QUERY(QUERY({A2:A\ B2:B+(ROW(B2:B)*0,00000001)};
"select count(Col1) where Col1 is not null group by Col1 pivot Col2"); "limit 0"; 1); 0); ))
;;999^99)); " ")))); 1; 0)));;999^99));;999^99); "♦")); "♠"); 2; 1); 2; 0)))