Merge multiple rows into one based on common column values

I have a data table where I have some rows which have all the columns values same except one (note column). I want to merge that row in to one. Example is below

Thanks in Advance

Hi,

Can you try the following sample?

dt = dt.AsEnumerable.GroupBy(Function(r) Tuple.Create(r(0).ToString,r(1).ToString,r(2).ToString,r(3).ToString)).Select(Function(g) dt.Clone.LoadDataRow({g.Key.Item1,g.Key.Item2,g.Key.Item3,g.Key.Item4,String.Join(",",g.Select(Function(r) r("note").ToString))},False)).CopyToDataTable

Sample20230210-4L.zip (8.4 KB)

Regards,

1 Like

It worked but the only issue is I have 26 columns in the data table and they are empty now

HI,

Can you share your input as file? It’s no problem if dummy data.

Regards,

@Yoichi
Here you go

regex_Clark_2023_02_10 (1).xlsx (9.5 KB)

HI,

The following is grouping by column “Booking No”,“Booking Component ID”, “Item No” and “Booking Status” and concatenate string in “note” column. In remaining column, the first row is kept. Does this work for you?
Or do you need grouping by all the columns except “note” column?

Sample20230210-4Lv2.zip (21.2 KB)

Regards,

1 Like

thanks @Yoichi . This will work. Thanks for your help

1 Like

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