Excel Get the Max and Min Values of Each Column in Each Group and Insert Them into Cells Horizontally

Excel Get the Max and Min Values of Each Column in Each Group and Insert Them into Cells Horizontally

Problem description & analysis

In the following table, the 1st column is the grouping column and there are N detail data columns after it.

ZN_1N_2Q_12
A100200-100
A101-10-200
A102201-104
A99199300
B100011001300
B10041200-900
C2000-21002200
C1900-2090-2180

The computing task: group rows by the 1st column; insert the maximum value and the minimum value of each column in each group in order into the 2N columns horizontally.

ZN_1MaxN_1MinN_2MaxN_2MinQ_12MaxQ_12Min
A10299201-10300-200
B10041000120011001300-900
C20001900-2090-21002200-2180

Solution

Use SPL XLL to enter the following formula:

=spl("=f=(d=E(?)).fname().m(2:),d.groups(Z;${f.( replace( ""max(*):*Max,min(*):*Min"", ""*"", ~ )).concat@c()})",A1:D9)

r/esProc_Desktop - Excel Get the Max and Min Values of Each Column in Each Group and Insert Them into Cells Horizontally

Explanation

fname()function gets column names of the table. groups() function groups the rows and perform aggregations. m(:2) gets members from the 2nd to the last, and ~ represents the current members. ${} takes the string as a dynamical code to execute.

esProc Desktop SPL XLL is now FREE to download and feel free to give it a try! http://www.scudata.com/download-Desktop