Linq Query to update serial number

Hi Team,

Can someone help me with the linq query to update a column with increased order.
I need increased number category wise. ()

like

Column1 Column2
Yes 1
Yes 2
Yes 3
No 4
No 5

for me result is like -

Column1 Column2
Yes 1
No 2
Yes 3
Yes 4
No 5

Thanks

Hi @radhagangwani0
you can try this code in invoke code with dt1 as In/Out

dt1.AsEnumerable().ToList().ForEach(Sub(row) row(“Column2”)= dt2.Rows.IndexOf(row)+1)

dt1 and dt2 should be arguments passed as

Regards,
Nived N
Happy Automation

Thanks, But i want category wise serial numbers.

Example-

Column1 Column2
Yes 1
Yes 2
No 4
Yes 3
No 5
No 6

But my doubt , do the first No should starts with 1 instead of 4 , is it right ?

I have 2 categories- Yes and No
First for all yes – 1,2,3,…N
the for all Nos – N+1, N+2…

Answer to your question is - No will start from 4 because last Yes =3

This has been solved now, Thanks !!!

1 Like