13.7 Re-group or sort when filling grouped data into columns

 

There is a data table. In this table, the products with the same name may have multiple colors.

imagepng

The task is to convert the data to the form as shown below, that is, arrange each type of product in one row, and then list the Name and Color of each product in turn.

imagepng

Script:

=spl("=E(?1).group(Type).(~.group(Name)).((~.Type|~.(Name|~.(Color))).conj@r())",Sheet1!A1:C8)

First group by Type, and then group by Name in each group.
Loop through groups of Type. First take Type, and then add the sequence composed of Name and Color of each group in its Name subgroups, and finally use conj to concatenate the sequence. Option @r means recursive calculating until all members are no longer a sequence.


esProc Desktop and Excel Processing
13.6 Put data in a group horizontally into columns
13.8 Convert certain columns of the same row, as group members, to multiple rows