DEV Community

Cover image for #122 — Put Every N Members in a Group
Judith-Excel-Sharing
Judith-Excel-Sharing

Posted on

#122 — Put Every N Members in a Group

Problem description & analysis:

Here below is a data table:

source table

Task: We want to put every 4 rows in order in a group, and calculate the serial number of the group and the sum of the values in the second column of each group.

Solution:

Use SPL XLL and enter the following one-line code:

=spl("=E@b(?1).groups((#-1)\4+1:ID;sum(#2):Total)",A1:B12)
Enter fullscreen mode Exit fullscreen mode

The results are as follows:

result table

To put every 4 rows in a group, we can group by the result of (#-1)\4+1, that is, subtract 1 from row number # to get the difference, divide the difference by 4 to get the quotient, and add 1 to the quotient. After grouping, we can count the sum of the values in the second column of each group.


Download esProc Desktop for FREE and work smarter with your data using SPL XLL!! 🚀✨⬇️

✨SPL download address: esProc Desktop FREE Download

✨Plugin Installation Method: SPL XLL Installation and Configuration

✨References to other rich Excel operation cases: Desktop and Excel Data Processing Cases

✨YouTube FREE courses: SPL Programming

Top comments (1)

Collapse
 
judith677 profile image
Judith-Excel-Sharing

Wishing you peace, joy, and productive holidays! 🎄✨🌟
And feel free to join the communities:

⭐️Discord
⭐️Reddit