I'm trying to transform my clasic formula to a dynamic array one, but i can't
My current working classic formula is
=LET(
per; B4;
data; FILTER(CHOOSE({1\2}; Taula1[Cap];Taula1[Cap]*Taula1[Tipo]); Taula1[Per]=per);
res; SUM(INDEX(data;;2)) / SUM(INDEX(data;;1) );
res)
But it doesn't run when i'm trying to transform the formula changing the parameter to a dynamic array B4#
Now I copy/paste the classic formula to next rows
The result must be:
And source data was:


=LET( per, B4#, data, FILTER(CHOOSE({1,2,3}, Taula1[Per],Taula1[Cap],Taula1[Cap]*Taula1[Tipo]), ISNUMBER(XMATCH(Taula1[Per],per))), uniq,UNIQUE(INDEX(data,,1)), rowwise,BYROW(uniq,LAMBDA(x,SUM(--(x=INDEX(data,,1))*(INDEX(data,,3)))/SUM(--(x=INDEX(data,,1))*(INDEX(data,,2))))), HSTACK(uniq,rowwise))