13.3 Convert crosstab to row-based table
We have a crosstab that stores product’s style data (width and length) and price information. The width data are stored in the first row, and the length data are stored in the first column:
Now we want to convert this table to a row-based table, and show product style as width*length, like this:
Script:
=spl("=E(?1).pivot@r(Style:Length;Width,Price).select(Price).sort(Width,Length).new(Width/""*""/Length:Style,Price)",Sheet1!A1:K16)
Perform the column-to-row conversion based on Style column, and give it a new name Length; the option @r means column-to-row conversion; the original column names are transferred and used as the values in the new column Width, and the original values in the cross cells are transferred and used as the values in the new column Price.
After that, select the rows whose value in column Price is nonnull, and sort them by Width and Length; create a new dataset, with “Width*Length” as the values in the new column Style, and take the Price column as the price column of the new dataset.
https://c.scudata.com/article/1651916536524
https://c.scudata.com/article/1657845306786
https://c.scudata.com/article/1658065366055
SPL Official Website 👉 https://www.esproc.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_Desktop/
SPL Learning Material 👉 https://c.esproc.com
Discord 👉 https://discord.gg/2bkGwqTj
Youtube 👉 https://www.youtube.com/@esProcDesktop
Linkedin Group 👉 https://www.linkedin.com/groups/14419406/