Reputation: 43
I am not able to use RANK
in grouped rows within an ARRAYFORMULA
.
I have a big dataset (≈100.000 rows) where I want to create an ARRAYFORMULA
that makes a different RANK
for the rows that share the same identifier.
Although I get the result without problems dragging a formula (combining RANK
and FILTER
), I am not able to replicate the result with an ARRAYFORMULA
. This file with dummy data replicates the problem.
In advance, thank you so much for your help.
Upvotes: 0
Views: 862
Reputation: 1
also solution:
=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)))
Upvotes: 0
Reputation: 34230
You can do it with sorting and counting in principle, but it's difficult in practice because the functions you would like to use like Countifs aren't array friendly. Here is a rather long-winded way of doing it where you sort, Vlookup on a combination of Slug and Points, get the matching row number and subtract the row number you get from a Vlookup just matching on Slug:
=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,""))
Upvotes: 2