Hello!
I have a List with the following data:
List(3) { “13.04.2023”, “14.04.2023”, “17.04.2023” }
I also have a Datatable with the following data on Column A:
13.04.2023
17.04.2023
The point is, I need to remove the two dates that can be found in the datatable from the list, so that my list can look like this at the end:
List(1) { “14.04.2023” }
Does anyone know how can I achieve this using a Linq expression?
Thank you!
Hi
Welcome to UiPath forum
Hope the below steps would help you resolve this
First let’s get the datatable column as a list of string and then compare with the list variable u already have
To convert a datacolumn as a list of string use this expression in a assign activity
List2 = ( From row in dt.AsEnumerable() Select Convert.Tostring(row(“ColumnName”)) ) .ToList()
And now compare these two list variables to get the difference in them
List_output = list1.Where(Function(x) not list2.Contains(x)).toList()
U can place the list variables in the expression vice versa as per ur need
Cheers @Alexandru_Florin
1 Like
ppr
(Peter Preuss)
April 26, 2023, 12:09pm
3
Assign activity
arrDTValues =
yourDataTableVar.AsEnumerable().Select(Function (x) x("Column A").toString.Trim).toArray
Assign activity
YourListVar = YourListVar.Except(arrDTValues).toList
1 Like
Hi @Alexandru_Florin ,
Heres another approach:
ListVariable.Except(datatableVariable.AsEnumerable().Select(Function(row) row("Column A").ToString())).ToList()
Regards,
1 Like
It worked! Thank you very much!
1 Like
Glad it got resolved @Alexandru_Florin
1 Like
system
(system)
Closed
April 29, 2023, 12:18pm
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.