11.6 Put every N members in a group

 

Here below is a data table:

imagepng

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

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

imagepng

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.