Hi,
I have Col1,Col2,Col3,Col4
Where i have to get distinct elements from col1 and its corresponding Col3 value and store the data in dictionary format(Key : Col1 , Value :
Col3).Can someone please help?
Hi,
I have Col1,Col2,Col3,Col4
Where i have to get distinct elements from col1 and its corresponding Col3 value and store the data in dictionary format(Key : Col1 , Value :
Col3).Can someone please help?
Hi,
Can you try the following expression?
dict = dt.AsEnumerable.GroupBy(Function(r) r("Col1").ToString).Where(Function(g) g.Count=1).ToDictionary(Function(g) g.Key,Function(g) g.First().Item("Col3").ToString )
Sample20220108-1.zip (2.8 KB)
Regards,
@Yoichi Your solution was helpful fr abit but actually i want all the unique elements like take the first element and ignore the next duplicates.Can you please help with it?
Hi,
Alright. How about the following?
dict = dt.AsEnumerable.GroupBy(Function(r) r("Col1").ToString).ToDictionary(Function(g) g.Key,Function(g) g.First().Item("Col3").ToString )
Sample20220108-1v2.zip (2.8 KB)
Regards,
It helped thank you.
thanks a lot @Yoichi @arivu96 both the solutions really helped infact yoichi solution was more of efficient for my scenario.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.