#41 — Group And Summarize Rows While Retaining Columns Whose Values Are Unchanged

#41 — Group And Summarize Rows While Retaining Columns Whose Values Are Unchanged

Problem description & analysis:

In the Excel table below, the ID column is the category; Value1 and Value2 contain numbers; both Descr 1 and Descr 2 remain unchanged under the same ID value.

ABCDE
1IDValue 1Value 2Descr 1Descr 2
2112.51.8ax1
3112.31.1ax1
4111.91.6ax1
5123.73.5bx2
6123.91.5bx2
7132.50.2cx3
8132.64.1cx3
91324.8cx3
10132.71.8cx3

This is an older version of Excel (which does not support groupby function). Task: Group rows by ID and sum the Value1 field and Value2 field while retaining the Descr 1 field and Descr 2 field.

GHIJK
1IDValue 1Value 2Descr 1Descr 2
2116.74.5ax1
3127.65bx2
4139.810.9cx3

Solution:

Use SPL XLL to get this done:

=spl("=E(?).groups(ID;sum('Value 1'):'Value 1',sum('Value 2'):'Value 2','Descr 1','Descr 2')",A1:E10)

As shown in the picture below:

r/esProc_Desktop - Group And Summarize Rows While Retaining Columns Whose Values Are Unchanged

Explanation:

E()function converts a data arrangement to a table. groups() function groups and summarizes the table, during which a newly generated column can be renamed through the semicolon.

Please feel free to download esProc Desktop and boost our Excel productivity with SPL XLL! ⬇️

SPL download address: esProc Desktop Download

Plugin Installation Method: SPL XLL Installation and Configuration

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

SPL Programming (YouTube FREE courses): https://www.youtube.com/playlist?list=PLQeR-IhHo7qNCw6o7PW8YfHvRx8pgzZso