Write unique value in the Columns

Hi Team,

One of the Datatable having one columns “AllUserName” has multiple name in a single cell.

So that i want to write a unique name as showing some sample input and expected output details

image

image

Thanks
Shyam

Hi @Shyam_Pragash

Try this:

outputDataTable = (From row In inputDataTable.AsEnumerable()
                   Let uniqueNames = String.Join(",", row.Field(Of String)("AllUserName").Split(",").Distinct())
                   Select outputDataTable.Rows.Add(uniqueNames)).CopyToDataTable()
1 Like

Hi @Shyam_Pragash

Try this

Code:

(From row In DT.AsEnumerable()
                       Let uniqueNames = String.Join(",", row("AllUserName").ToString().Split(","c).Select(Function(name) name.Trim()).Distinct())
                       Select DT.Clone.Rows.Add({uniqueNames})).CopyToDataTable()

I/P:
image

O/P:
image

Hope this helps!!

Hi @supriya117 @lrtetala

Thanks its working fine…

2 Likes

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