Rhys18
(Rizky Albert Hartono)
July 6, 2022, 10:50am
1
Hi,
I have a set of data like this from excel file with the expected output :
so I have a data that can be seen in the picture. My goal is I have to get the highest price of each car type.
How to do it in UiPath? The sequence is write from excel to another excel
ppr
(Peter)
July 6, 2022, 11:09am
2
assign Acitvity
dtResult = yourOriginDataTableVar.Clone
Assign Activity
dtResult =
(from d in yourOriginDataTableVar.AsEnumerable
Group d by k=d("Car Type") into grp = Group
Let mx = grp.Max(Function (x) CInt(x("Price").toString.Trim))
Let ra = new Object(){k,mx}
Select r = dtResult.Rows.Add(ra)).CopyToDatable
Rhys18
(Rizky Albert Hartono)
July 6, 2022, 11:26am
3
This case is only with 2 columns only and we just process the data table.
Can it be done with a variable like string? Assuming the data is now like this
can it be processed maybe split or filter?
ppr
(Peter)
July 6, 2022, 11:35am
4
prepare with e.g. build datatable activity an empty datatable within the two-column structure instead
This HowTo introduces on the different options for grouping data from a datatable in order to process the grouped data.
Introduction
Grouping data and processing the grouped data is a common scenario e.g. when the grouped data is to aggregate like summing up, find maximum, get the average or concatening items.
Lets have a look on following data:
[grafik]
A possible scenario could be:
Create a report containing following information:
the region code
the sum of CaseCount per RegionCode
t…
inputDT.Asenumerable.Groupby(Function(r) r(“car type”).Tostring).Select(Function(g) DT2.Rows.Add({g.key,g.Asenumerable.Max(Function(r) CInt(r(“Sold Price”)))})).copytodatatable
Rhys18
(Rizky Albert Hartono)
July 7, 2022, 2:43am
6
Hi,
I just notice you are using LinQ queries… Thanks for the explanation I will take it as a new knowledge since I am currently on deadline thank you !
Rhys18
(Rizky Albert Hartono)
July 7, 2022, 2:45am
7
Hi,
I tried your solution but I go this error instead :
‘Comma, ‘)’ or a valid expression continuation expected’
I tried to fix the brackets () and it’s still throwing the same error.
At the End …After “}” You Need to keep only 2 “)” .
Rhys18
(Rizky Albert Hartono)
July 7, 2022, 3:38am
9
Yes the first time I copy paste your code it’s throwing that error
Anyway …Is it working Fine For you ?
Rhys18
(Rizky Albert Hartono)
July 7, 2022, 3:40am
11
Nope it’s not, the error is still there
Rhys18
(Rizky Albert Hartono)
July 7, 2022, 3:42am
13
Here is the code
dt_input_filtered_2.Asenumerable.Groupby(Function(r) r("Type").Tostring).Select(Function(g) DT2.Rows.Add({g.key,g.Asenumerable.Max(Function(r) CInt(r("Sold Price"))})).copytodatatable
Ok …I edited Query Check it once.
Rhys18
(Rizky Albert Hartono)
July 7, 2022, 3:48am
15
Okay it’s not showing error anymore ! But I got a question to ask.
InputDT is the variable where it contains the Car Type and Sold Price
What is Dt2 for? Some kind of temp to store the Car Type and Sold Price
DT2 For store the Final Output
1 Like
Rhys18
(Rizky Albert Hartono)
July 7, 2022, 3:51am
17
Ok thanks for the help Mr. Gangadhar!
system
(system)
Closed
July 10, 2022, 3:52am
18
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.