Group unique rows from Column A and add other sum rows of Column B

Hi All,
I have a excel that contains Column Tracking Number ,SKU (string )and TotalOrder(int)

1.I need to find unique rows in Tracking Number
2. Append SKU
3.Add TotalOder
Input

Thanks ,I will try this

(From d In dtData.AsEnumerable
Group d By k=d(“TrackingNumber”).toString.Trim Into grp=Group
Let cs = grp.Sum(Function (rc) CInt( “0” & rc(“TotalOrder”).toString))
Let cn = String.Join(“;”, grp.Select(Function (rn) rn(“SKU”).toString).toArray)
Let ra = New Object(){k, cs, cn}
Select dtReport2.Rows.Add(ra)).CopyToDataTable

Perfect, this is a good first start

Let cs = grp.Sum(Function (rc) CInt( “0” & rc(“TotalOrder”).toString))

kindly note: the “0”& Trick will fail on negative numbers.

So we suggest the following:

Let cs = grp.Sum(Function (rc) CInt( rc("TotalOrder").toString.Trim))

And if blanks / non valid numbers are to expect handle it before / within once the Business Requirements are redefined and specifying it in detail

What to give when we need a column after grouping without any changes ?

In general

Group d By k1=d(“TrackingNumber”).toString.Trim, k2=d(“ShippdedDate”).ToString.Trim Into grp=Group

for Dates we do also check if maybe a parsing into datetime before using it within the group definition could be a better approach. Datails on this depends also on the data source

1 Like

shipped Date is in “Date” format in source . Kindly help me with this .

Convert.ToDateTime(d(“ShippedDate”).ToString(“dd/mm/yy”) is not working

As mentioned:

:ambulance: :sos: [FirstAid] Datatable: Debug & Analysis invalid DateTime Strings / String to DateTime Parsing Issues - News / Tutorials - UiPath Community Forum

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.