LINQ Update Data Issue

Hi…

i have two datatable in the flow…

try to merge data based on column name…

i got this result…

image

My Flow…

Expected Output:
image

Thanks
Shyam

1 Like

Hey @Shyam_Pragash

You shouldn’t be using two From keyword.

Thanks
#nK

Hi @Nithinkrishna

i dont have any keywork to merge data…

Randomly value add value in define position.

didnt use any lookup or check the condition… Just add it.

Thanks
Shyam

1 Like

Hey @Shyam_Pragash

Just try replacing second from with , in the code.

Or try the below.

dt1.AsEnumerable.Select(Function(row, index) dtResult.Rows.Add(new object(){ row(0).ToString, row(1).ToString, dt2.Rows(index)(0).ToString })).CopyToDataTable

Thanks
#nK

1 Like

your result comes from the nature of the cartesian product.

Your case looks similar to a side by side merge

we can do it by writing out excel2 with an offset or LINQ

(From x in Enumerable.Range(0, dt1.Rows.Count)
Let r1 = dt1.Rows(x)
Let r2 = dt2.Rows(x)
Let ra = new Object(){r1(0), r1(1), r2(0)}
Select row=dtResult.Rows.Add(ra)).CopyToDatable
3 Likes

Hi.

Thanks for you repy…

i tried above code… i got error “Assign: There is no row at position 3.

Main.xaml (17.3 KB)

Thanks
Shyam

1 Like

Hey @Shyam_Pragash

The row count should be the same for DT1 and DT2 as you mentioned. Else it will throw an error as you are getting now.

Thanks
#nK

Hi @Nithinkrishna @ppr

Thanks you :slight_smile:

Thanks
Shyam

1 Like

Welcome :hugs: @Shyam_Pragash

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