Linq support

I have a datatable that has Column A , B , C D E, D is only blank column now I want to do is I want the values from C column to be picked one after the other and check that in Column A if available then pick corresponding value from Column B and populate the data in Column D

We will need more detail about the scenario as your explanation is unclear.
It would be great if you can give sample input and output.

Sir this makes no sense. Rewrite your question.

Hi @manoj2500

If C value exists in Column A, then should take the matching value from Column B
and write it into Column D.

If this is the scenario, Create an Invoke Code activity , set arguments, use following code.

Code :
For Each row As DataRow In dt.Rows
Dim result = dt.AsEnumerable().
Where(Function(r) r(“A”).ToString.Trim = row(“C”).ToString.Trim).
Select(Function(r) r(“B”).ToString).
FirstOrDefault()
row(“D”) = If(result Is Nothing, “”, result)
Next


If helpful, mark as completed. Happy automation :slight_smile:

input.xlsx (8.4 KB)
outputdata.xlsx (8.4 KB)

I have attached the sample data

Input sheet has A,B,C,D and E columns D is blank
once i read this as Dt now i want to pull records of Column C ex: 1st Value 745896
this value now i will check in Column A once found i will get the corresponding value of that cell in B column i.e Q78259 in same way i want to populate column D values. I have tried for each but that is taking lot of time looking for some faster approach @AkshaySandhu @David_Hernandez2 @MohammedShabbir

Hi @manoj2500

Its working as expected. verify this. I have attached the code.


Sequence1.xaml (10.0 KB)

If helpful, mark as solution. Happy automation

3 Likes

I know solution is already accepted but here is more cleaner version:

Dim Dict_LookUP As Dictionary(Of String, String) = new Dictionary(of String, String)

Dict_LookUP = dt.AsEnumerable().ToDictionary(Function(row) row("Org").ToString,Function(row) row("External").ToString)

For Each row As DataRow In dt.AsEnumerable
	If Dict_LookUP.Keys.Contains(row("Parent").ToString) Then		
		row("User") = Dict_LookUP(row("Parent").ToString).ToString
	End If	
Next row
2 Likes

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