Auto-delete Empty Detailed Rows after Grouping

Problem description & analysis

Below is Excel file Book1.xlsx:

ID

Criteria1

Criteria2

Criteria3

Criteria4

101

2

102

7

123

93

123

8

123

6

123

17

182

6

182

9

182

39

182

120

182

147

We are trying to group rows by ID and sum values in the other columns. Below is the desired result:

ID

Criteria1

Criteria2

Criteria3

Criteria4

101

2

102

7

123

93

25

6

182

6

9

39

267

Solution

Write the following script p1.dfx in esProc:

A

1

=file("Book1.xlsx").xlsimport@t()

2

=A1.groups(ID;sum(Criteria1):Criteria1,sum(Criteria2):Criteria2,sum(Criteria3):Criteria3,sum(Criteria4):Criteria4)

3

=file("result.xlsx").xlsexport@t(A2)

Explanation:

A1   Import data from the Excel file as a table sequence.

A2  Group rows by ID  and sum each Criterial column.

A3  Export A2’s result to result.xlsx.

Q & A Collection

https://stackoverflow.com/questions/63673362/sum-by-unique-id-and-auto-deletion