dear all , i have an excel file as follow
in column a ,if the cell is same and in column c the data1 is the same, then add the data2 into one cell ,the result like following picture
anyone could help me ? give me a demo xaml code, thanks a lot in advance!!!
pay attention: only the row name is the same , and the number in row data1 is the same, we just add the number in data2, if name is the same,but the number in data1 is not the same ,we do not add, anyone could help me ? thanks a lot in advance!!!
(From row In dt_Input.AsEnumerable()
Group row By Name = row.Field(Of String)("Name") Into Group
Let Time = CInt(Group.First().Field(Of Double)("Time"))
Let Data1 = Group.First().Field(Of Double)("Data1")
Let Data2Sum = Group.Sum(Function(r) r.Field(Of Double)("Data2"))
Select dt_Input.Clone().Rows.Add(Name, Time, Data1, Data2Sum)).CopyToDataTable()
(From row In dt_Input.AsEnumerable()
Group row By Name = row.Field(Of String)("Name") Into Group
Let Time = CInt(Group.First().Field(Of Double)("Time"))
Let Data1 = Group.First().Field(Of Double)("Data1")
Let Data2 = String.Join("+", Group.Select(Function(r) r.Field(Of Double)("Data2")))
Select dt_Input.Clone().Rows.Add(Name, Time, Data1, Data2)).CopyToDataTable()
=> Use Rad Range Workbook to read the excel and store it in an DataTable say dt.
=> Use the below syntax in Assign activity:
dt= (From row In dt.AsEnumerable()
Group row By Name = row.Field(Of String)("Name") Into Group
Let Time = CInt(Group.First().Field(Of Double)("Time"))
Let Data1 = Group.First().Field(Of Double)("Data1")
Let Data2 = String.Join("+", Group.Select(Function(r) r.Field(Of Double)("Data2")))
Select dt.Clone().Rows.Add(Name, Time, Data1, Data2)).CopyToDataTable()
=> Use Write Range Workbook to write it back to excel in different sheet.
Make sure you replcae the datatable variables with yours. Try updating UiPath.System.Activities to latest version. I have shared the workflow file xaml for your reference too.
May be you could replicate the process flow with the help of workflow image. I have the output variable of the Read Range Workbook Excel data in assign acitivty.
only the row name is the same , and the number in row data1 is the same, we just add the number in data2, if name is the same,but the number in data1 is not the same ,we do not add, anyone could help me ?
hey irtetala , we have to pay attention only the row name is the same , and the number in row data1 is the same, we just add the number in data2, if name is the same,but the number in data1 is not the same ,we do not add.
I use this zip file , but it not right.
for example , if the excel table like follow, the name b have two row, but the number in row data1 is not same , it is 2.32% and 2.27% , we need not add the data2 , but your code , the output b is 10E+20E in row data2
|Name|Time|Data1|Data2|
|a|3M|2.25%|1E|
|b|3M|2.32%|10E|
|b|3M|2.27%|20E|
|c|3M|2.28%|0.5E|
|d|3M|2.35%|4E|
|e|3M|2.35%|1E|
for example , if the excel table like follow, the name b have two row, but the number in row data1 is not same , it is 2.32% and 2.27% , we need not add the data2 , but your code , the output b is 10E+20E in row data2
|Name|Time|Data1|Data2|
|a|3M|2.25%|1E|
|b|3M|2.32%|10E|
|b|3M|2.27%|20E|
|c|3M|2.28%|0.5E|
|d|3M|2.35%|4E|
|e|3M|2.35%|1E|