=DROP(REDUCE("",UNIQUE(H3:H32),LAMBDA(m,n,LET(a,FILTER(G3:K32,(G3:G32=A1)*(H3:H32=n)),jg,DROP(REDUCE("",UNIQUE(INDEX(a,,3)),LAMBDA(x,y,VSTACK(x,HSTACK(n,y,SUM(TAKE(a,,-1)*(INDEX(a,,3)=y)))))),1),VSTACK(m,TAKE(SORT(jg,3,-1),3))))),1)
=DROP(REDUCE("",TAKE(SORT(HSTACK(UNIQUE(I3:I32),SUMIFS(K:K,I:I,UNIQUE(I3:I32))),2),-3,1),LAMBDA(m,n,LET(a,FILTER(G3:K32,(G3:G32=A1)*(I3:I32=n)),jg,DROP(REDUCE("",UNIQUE(INDEX(a,,4)),LAMBDA(x,y,VSTACK(x,HSTACK(n,y,SUM(TAKE(a,,-1)*(INDEX(a,,4)=y)))))),1),VSTACK(m,TAKE(SORT(jg,3,-1),3))))),1) |