Group By ID and merge

Hi Team,

I’ve data in excel in below formatdata.xlsx (9.5 KB)

I need to Group data by ID and merge two document number like this way result.xlsx (8.3 KB)

can anyone help. Thanks

Currently it looks like remove duplicates

For groupby also have look here:

1 Like

Hi @ppr,

can you please share code for this particular input file

Thanks

please tell uns on what you are interested. Remove duplicates we can do with Remove Duplicates Row Activity

Hi @ppr,

Sometime in the excel posted to SAP false in runtime in that case No document number is generate for one ID, but for 2nd ID posted for SAP can be true in runtime and document number got generatedSample Input.xlsx (11.2 KB)

sometime input file looks this way… Please suggest what is better

please provide also corresponding output sample. Thanks

If we would group data which column(s) should be used grouping?

output will look like thisOutput.xlsx (11.1 KB)

Please check the summary of your requirements and ensure that all cased are defined and covered:

  • Rows are grouped on ID Column Value
  • If a group has multiple members
    • take member rows, where COL document_number is not empty (ALL)
  • If a group has no multiple members
    • PLEASE specify what is to do

for a starter help give a try on:

(From d In YourDataTableVar.AsEnumerable
Group d By k= d("ID").toString.Trim Into grp=Group
Let gmb = grp.Where(Function (x) Not (isNothing(x("document_number")) OrElse String.IsNullOrEmpty(x("document_number").toString.Trim)))
Let chk = gmb.Count > 0
Let res = If(chk, gmb, grp)
Select r=res).SelectMany(Function (x) x).CopyToDataTable