How to insert Group by data from old Data table to a new table?

excel
activities

#1

Hi everyone,
DT1: name, id, etc
Jack, 11
Tom, 12
Jerry, 13
Jack, 28
Jerry, 27

Result:
DT2: name, id, etc
Jack, 11
Jack, 28
DT3: name, id, etc
Jerry, 13
Jerry, 27
DT4: name, id, etc
Tom, 12

thanks for any suggestions!


#2

Hi @Jolin,
You can use this activity . It will return the result as datatable.

I have use the read range activity. so you must have to install the Uipath.Excel.Activity.

Regards
Balamurugan


#3

Hi @balupad14,

Thanks for your reply. I tried to use the activities you suggested, but I still can not insert Group by data into a new table. DT1 data can be added or deleted dynamically. Could you give me more suggestions?


#4

Hi @Jolin,
Is it possible to attach the source ?
Regards
Balamurugan


#5

Hi @balupad14,

the source files:
test_name.xlsx (8.1 KB)
newTable.xaml (7.4 KB)


#6

Hi @Jolin,
Thank you for using the “BalaReva.DataTable.Activities”. I have modified your source that I have attached it here.

File : GroupInsert.zip (12.9 KB)

I need to share some points with you.

  1. Normally when you read the data from excel. all fields are string type.
  2. In that case you have to use the property “AggregateType” to “Integer or Double.”

This week or next week , It has a new release with some new features.

Thank you
Balamurugan.S


#7

Hi @balupad14,

Thanks for your reply, but that’s not what I want :expressionless:. I just want to Group by(name),not SUM(money), then insert the same name to a new table. Finally ,the new table can be written into a excel.

Can you understand what I mean? :grinning:

Appreciated for your any suggestions.


#8

Hi @Jolin,
As I understand that you are going to remove the duplicates . In that case you can use the DefaultView from Datatable like below.

dtNew=dt.DefaultView.ToTable(True,“Column1”,“Column2”,“Column3”,“Column4”) [Specific columns]
or
dtNew=dt.DefaultView.ToTable(True) [All the columns]

Regards
Balamurugan


How to distinct the excel
#9

Hi @balupad14,

Thanks very much for your reply.
Sorry that I didn’t describe the problem clearly, I have attached the output file for a better understanding.outData_file.xlsx (10.4 KB)

Looking forward to your reply :smiley:


#10

Hi @Jolin

About your question, I commend an easy way.

DV1 = DT1.DefaultView
DT1_name = DV1.toTable(True, “name”)

For Each name In DT1_name

DT(2,3,4…) = DT1.select(“name=’”+name+"’", “id”)

Next

Maybe will help you.


#11

Hi @Jolin,
I saw the xl file. I didn’t understand your expectation result. if you do the group by name, nothing happens in the data. Because you are not going to use the aggregation. Please specify your expected result.

Regards
Balamurugan


#12

Hi @wusiyangjia,

Thanks very much for your suggestion, it’s such an easy way. Under your help, I have already finished it :star_struck:.