How to find Most repeating value in a column (part of a datatable) using LINQ in UiPATH

How to find Most repeating value in a column (part of a datatable) using LINQ in UiPath. My column format is:
Col1 Col2
D1 3
D2 6
D3 2
D4 6
D5 5
D6 6
Here I need answer as 6

1 Like

hi @Tech

check this

use this code in assign Activity
(DT.AsEnumerable().GroupBy(Function(r) cstr(r("Column2"))).OrderByDescending(Function(g) g.Count()).Take(1).Select(function(n) n.Key)).tolist

1 Like

Try with this

In assign activity

stroutput =
(From row In dt.AsEnumerable()
Group row By Col2 = row.Field(Of Integer)(“Col2”) Into Group Order By Group.Count() Descending Select Col2).FirstOrDefault().ToString

Cheers @Tech

1 Like
(From d in dtVar.AsEnumerable
Group d By k=d("Col2").toString.Trim into grp=Group
Order by grp.Count
Select x=k).Last()
1 Like

H! @Tech

Can you try this

dt.AsEnumerable() _
.GroupBy(Function(row) row.Field(Of String)(“VAL”)) _
.OrderByDescending(Function(grp) grp.Count()) _
.Select(Function(grp) grp.Key) _
.FirstOrDefault()

output :-

2 Likes

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