Compare 2 datatble and update the very first matching value

Hi,

I have a 2 datatable consider dt1 and dt2,I need to compare the column1 of dt1 with column1 of dt2 and update the column2 of dt1 with column2 of dt2.I am able to update the value but in dt2 there is a 2 matching value,so I want to take the very first match and update .
Please help me for linq query.

Dt1

Dt2

Output dt

If you see in dt2 the value abc have 2 value but I want to take the 1 st value.

Hi @yashashwini2322

=> Read Range Workbook
Output β†’ DT1

=> Read Range Workbook
Output β†’ DT2

=> Use the below code in Invoke Code:

Dim dt2Lookup As Dictionary(Of String, Double) = dt2.AsEnumerable() _
    .GroupBy(Function(row) row.Field(Of String)("column1")) _
    .ToDictionary(Function(g) g.Key, Function(g) g.First().Field(Of Double)("column2"))

For Each row In dt1.AsEnumerable()
    Dim key As String = row.Field(Of String)("column1")
    If dt2Lookup.ContainsKey(key) Then
        row("column2") = dt2Lookup(key)
    End If
Next

Invoke Code Arguments:

=> Write Range Workbook DT1 back to excel.

Workflow:

XAML:
Sequence3.xaml (8.3 KB)

Hope it helps!!

Hello @yashashwini2322 ,

Here’s the zip of workflow containing your required output.

Note in invoke code assign your 2nd datatable(where you need to get output) to β€œdt1”(In the arguments of Invoke code activity). As final output is going to be stored in β€œdt1” of the invoke code.
Let me know if you have any doubts

Vlookup.zip (2.1 KB)

If this helps do mark it as solution.
Cheers!!!

Hi @yashashwini2322

Try this

"=VLOOKUP(A2,Sheet2!A:B,2,0)"

Input:(Sheet1)

Input:(Sheet2)

Output:(Sheet1)

Regards,

Thank you,it working fine

1 Like

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