How to count the values

Hi Experts,

I’m stuck in a simple problem. Wanted to count the value of the excel.
| Values
1 Delhi
2 Mumbai
3 Delhi
4 Jaipur
5 Mumbai
6 Mumbai
7 Mumbai
8 Delhi
9 Jaipur
10 Mumbai

Expected result would be-

|Values |Count |
|Delhi |3 |
|Mumbai|5 |
|Jaipur |2 |

Please help me in solve this. Thanks in advance.

Hi @aayushisaxena125 ,

As you have already provided the Expected Output Table, we could Start by Preparing the Datatable Schema using Build Datatable Activity as shown in your post above.

Next, We Perform a GroupBy and Count based on the Values Column like below using Assign Activity :

OutputDT = DT.AsEnumerable.GroupBy(Function(x)x("Values").ToString).Select(Function(x)OutputDT.Rows.Add({x.First.Item("Values").ToString,x.Count})).CopyToDatatable

Here, OutputDT is the datatable built using Build Datatable Activity and DT is the Input Datatable.


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