Group an EXCEL table and concatenate values of rows meeting the specified condition
An Excel table has four columns, among which the 2nd one is the grouping column:
A |
B |
C |
D |
|
1 |
1 |
a |
1 |
yet |
2 |
2 |
a |
2 |
done |
3 |
3 |
a |
3 |
yet |
4 |
4 |
b |
1 |
done |
5 |
5 |
b |
2 |
done |
6 |
6 |
b |
3 |
done |
7 |
7 |
b |
4 |
yet |
8 |
8 |
b |
5 |
done |
We want to group rows of the table by the 2nd column, from each group find rows where values in the 4th column are "done", concatenate values of the 3rd column of these rows, and form a new table using the new column, grouping column and row number.
F |
G |
H |
|
1 |
1 |
a |
2 |
2 |
2 |
b |
1,2,3 |
Use SPL XLL to do this task:
=spl("=?.select(~4==$[done]).groups(~2;concat@c(~3)).(#|#1|#2)",A1:D7)
group()s function groups rows and handles each group; ~2 represents the 2nd child member of the current member. $[] represents a string. # is ordinal number of the current member; #1 is the 1st column of the table. concat@c concatenates members with the comma.
SPL Official Website 👉 https://www.scudata.com
SPL Feedback and Help 👉 https://www.reddit.com/r/esProc_Desktop/
SPL Learning Material 👉 https://c.scudata.com
Discord 👉 https://discord.gg/cFTcUNs7
Youtube 👉 https://www.youtube.com/@esProcDesktop
Linkedin Group 👉 https://www.linkedin.com/groups/14419406/