11.9 Group when meeting blank row

 

Here below is a data table:

imagepng

The data consist of multiple segments, and each segment includes N consecutive rows and 1 blank row. Now we want to calculate the sum of the values of each segment, and fill in the result in the cell of the blank row, column C, and keep the rest cells in column C null. To achieve this, enter the formula in cell C1:

=spl("=?1.conj().group@i(~[-1]==null).([null]*(~.len()-1)|~.sum()).conj().new(~:Total)",B2:B21)

imagepng

When the previous member is null, create a new group.
Loop through every group, calculate the sum of the values of each group, and make up null values in the cells above the sum cell of each group (the number of nulls should be the number of members minus 1).


esProc Desktop and Excel Processing
11.8 Take adjacent data as grouping criteria
11.10 Group when meeting non-null value