11.8 Take adjacent data as grouping criteria

 

Here below is a data table:

imagepng

The task is to group the data in the first column, and calculate the sum of the values in the second column of each group. Grouping criteria: when there is a difference of 5 or more between the current data and previous one, create a new group:

=spl("=E@b(?1).group@i(#1-#1[-1]>=5).new(#1:ID,~.sum(#2):Total)",A1:B12)

imagepng


https://c.scudata.com/article/1651916536524
https://c.scudata.com/article/1656990041639
https://c.scudata.com/article/1657071330957