You can also try this formula; It is similar to z, but the data has already been modified:
=LET(x,FILTER(A3:I20,I3:I20=1, A3:A20=K3), grp, CHOOSECOLS(x,8), name, CHOOSECOLS(x,3), gender, CHOOSECOLS(x,5), id, CHOOSECOLS(x,4), weight, CHOOSECOLS(x,7), HSTACK(grp,name,gender,id,weight))
Sample Output: