#126 — Group When Encountering Non-Null Values

#126 — Group When Encountering Non-Null Values

Problem description & analysis:

We have an annual and monthly water-consumption data table, and the year is filled in only on the left of the first month of each year. Part of the data is shown as below:

Task: Calculate the total water consumption of each year.

Solution:

Use SPL XLL and enter the formula in cell D1:

=spl("=E(?1).derive(:TotalWater).group@i(Year!=null).run(~(1).TotalWater=~.sum(Water)).conj().new(TotalWater)",A1:C20)

The results are as follows:

When meeting a non-null value in the column Year, create a new group. Option @i means creating a new group when the condition is satisfied. Assign the sum(Water) of the current group to the first row of each group, and create a new data set and take out the TotalWater.


Download esProc Desktop for FREE and kick off 2025 with productivity 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