=STRUCTFIX(A3:E,{1,2},{3,4,5},C2:E2)
=LAMBDA(data,groupby_columns,columns_to_transpose,groupby_headers,MAP(TOCOL(BYROW(data,lambda(row,map(CHOOSECOLS(row,columns_to_transpose),groupby_headers,lambda(items,label,IF(items<>"",JOIN("|",CHOOSECOLS(row,groupby_columns),label,items),))))),3),lambda(results,split(results,"|"))))(data,groupby_columns,columns_to_transpose,groupby_headers)
This function allows to fix this type of data structure problem.
The first argument is to select all the data range without headers.
The second argument is to select which columns to group by in the form of
The third argument is to select which columns the data you need grouped by in the form of
The fourth argument is the headers for the columns for the data you need grouped by.