I have a scenario where I have to group by “ColumnC” and “ColumnD” and then get the count for those each distinct groups. Can someone provide me a linQ query? I can create logically, but it might be good to write a linQ than writing pages of UiPath code.
I need something like
Monday ------ 8.30 am ------5
Monday-------9.30 am -------4
Monday -------11.00 am -------10
Tuesday-------8.30 am ------6
Tuesday------- 11.30 am -------- 8
Wednesday---------9.30 am -------15
Wednesday --------11.30 am -------2
prepare an empty datatable with 3 cols: Day, Time, Count - w.g. with Build DataTable - dtResult
Assign Activity:
dtResult =
(From d in yourOriginDataTable.AsEnumerable
Group d by k1=d("Col1Name").toString.Trim, k2=d("Col2Name").toString.Trim into grp=Group
Let ra = new Object(){k1,k2, grp.Count}
Select r = dtResult.Rows.Add(ra)).CopyToDataTable
In case that the Timing needs a more detail analysis have a look here for some debugging / analysis techniques: