также решение:
синтаксис США
=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)))