DEV Community

Cover image for #50 — Group And Summarize Rows And Add Different Words After Different Counts
Judith-Excel-Sharing
Judith-Excel-Sharing

Posted on

#50 — Group And Summarize Rows And Add Different Words After Different Counts

Problem description & analysis:

An Excel table has two columns:

original table

Task: Group the table by the 1st column, and add 1 if the 2nd column in the current group is greater than 0; otherwise, do not add 1. If the count equals 1, add the word “Occurrence” after it; if it doesn’t, add its plural form “Occurrences” after it. Below is the expected result:

desired table

Solution:

Use SPL XLL to do this:

=spl("=E@b(?.group(~1;t=~.count(~2>0) / if(t==1,""Occurrence"",""Occurrences"")))",A1:B8)
Enter fullscreen mode Exit fullscreen mode

As shown in the picture below:

result table with code entered
Explanation:

group() function groups rows and handles each group of data. E@b removes column titles. ~1 represents the 1st child member of the current member in a sequence.

Top comments (2)

Collapse
 
judith677 profile image
Judith-Excel-Sharing

Feel free to download esProc Desktop and explore the data processing journey yourself ⬇️

🪄SPL download address: scudata.com/download-Desktop

🗝️Plugin Installation Method: c.scudata.com/article/1652061135502

🪄References to other rich Excel operation cases: c.raqsoft.com/article/1651916536524

🗝️SPL Programming (YouTube FREE courses): youtube.com/playlist?list=PLQeR-Ih...

Collapse
 
judith677 profile image
Judith-Excel-Sharing

Reach out to us if you have any Excel difficulties. Your problem may be listed in the next post of our series:

🧩Discord: discord.gg/PVyKVa2J
🧩Reddit: reddit.com/r/esProc_Desktop/