Hi ,
I need a help to get a distinct values from two datatables dt1 & dt2 the output should be in dt3.
DT1
Name
kkk
hhhh
pppp
rrrrr
hhj
DT2
Name
kkk
hhhh
pppp
Output DT3
Name
kkk
hhhh
pppp
Hi ,
I need a help to get a distinct values from two datatables dt1 & dt2 the output should be in dt3.
DT1
Name
kkk
hhhh
pppp
rrrrr
hhj
DT2
Name
kkk
hhhh
pppp
Output DT3
Name
kkk
hhhh
pppp
Try this:
Hope it helps!!
to get common values
dt1.AsEnumerable.intersect(dt2.AsEnumerable,system.Data.DataRowComparer.Default).CopyToDataTable
dt1.AsEnumerable.Except(dt2.AsEnumerable,system.Data.DataRowComparer.Default).CopyToDataTable
try this to get distinct
I have 3 others columns in DT1 and in DT2 only one column I need condition based on specific column @Parvathy @Shiva_Nikhil
Dt1.AsEnumerable().Where(Function(row) Dt2.AsEnumerable().Any(Function(x)
x(“ColumnName”).ToString=row(“ColumnName”).ToString)).CopyToDataTable
to get matches values of both datatables comparing one particular column
dt3 = (From row In dt1.AsEnumerable()
Select row
).Union(
From row In dt2.AsEnumerable()
Select row
).CopyToDataTable()
Your solution is working but it is failing when no value matches and getting error as “source contains no datarows”
in DT1 & DT2 if no value matches it is failing
we could shorten to
dt1.AsEnumerable().Union(dt2.AsEnumerable()).CopyToDataTable
Handling empty results we do:
[FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum
But we do feel, that a different result is expected which we will not produce with the union
Specific column will not work here I hope because in my scenario (DT1 has three columns and DT2 has only one )
yes, as we mentioned: