Concat values from 4 data columns

is there a way where i can concat values from 4 data columns, 2 from 1 datatable, and 2 from another datatable, exluding duplicate values, and blanks?

without for loop?

e.g.

DT 1
email 1 | email 2
aaaa@mads.com | bbbb@kso.com
xxxx@m.com | kkkk@m.com

DT 2
email 1 | email 2
aaaa@mads.com | kkkk@m.com
yyyy@asd.com | zz@ma.com

Output: aaaa@mads.com; bbbb@kso.com; kkkk@m.com; xxxx@m.com;yyyy@asd.com; zz@ma.com

@TyraS

Try this

requiredstring = String.Join(";",(string.Join(";",Dt1.AsEnumerable.Select(function(x) String.Join(";",x.Itemarray))) + ";" + string.Join(";",Dt2.AsEnumerable.Select(function(x) String.Join(";",x.Itemarray)))).Split(";"c).Distinct)

Cheers

Can you prepare a Excel file and create all sheets with respect to the all the input tables and expected output?

Regards,
Ajay Mishra

Hi @TyraS

=> Read Range Workbook
image
Output-> dt1

=> Read Range Workbook
image
Output-> dt2

=> Use below code in Assign:
distinctEmails = dt1.AsEnumerable().Select(Function(row) row("email 1").ToString().Trim()).Union(dt1.AsEnumerable().Select(Function(row) row("email 2").ToString().Trim())).Union(dt2.AsEnumerable().Select(Function(row) row("email 1").ToString().Trim())).Union(dt2.AsEnumerable().Select(Function(row) row("email 2").ToString().Trim())).Where(Function(email) Not String.IsNullOrWhiteSpace(email))

distinctEmails is of DataType iEnumerable(System.String)

=> Print in in Message Box
String.Join("; ", distinctEmails)


Sequence12.xaml (8.4 KB)

Hope it helps!!

we can condense, but would not exclude any options

Assign Activity
strFlat =

(From t In {dt1,dt2}
From v In t.AsEnumerable().SelectMany(Function (r) r.ItemArray)
Select s=v.ToString.Trim).Distinct().Aggregate(Function (x,y) x &";"& y)

Feel free to externalize {dt1,dt2} also into a variable