13.11 Rearrange multiple columns into a cross-tab

 

Here below is a data table:

imagepng

The task is to convert the data to the following form:

imagepng

Script:

A
1 =‘Sheet1!A1:C19’
2 =create(Meal,Name,Flag)
3 =A1.to(2,).run(~.run( if(~!=null,A2.record([A1(1)(#),~ , “√”]))))
4 =A2.pivot(Name;Meal,Flag)

A2: Create a table sequence having three columns Meal, Name and Flag
A3: Loop through every row starting from row 2 of A1, and then loop through the data sequence of each row; If the sequence member is not empty, insert its corresponding column name and itself into the table sequence of A2 in turn, and set Flag to √
A4: Group A2 by Name to perform row-to-column conversion, with the Meal values as new column names, and Flag as the new column values


esProc Desktop and Excel Processing
13.10 Convert groups to columns after grouping
13.12 Interconversion of rows and columns within a group