Count Number of Occurrences of Each Word in Column


How to Count Number of Occurrences of Each Word in Column using UiPath ?
Knowing that, I have found the following topic, but here we need to mention which word to count, and in my case, I need to fetch first all items and calculate the occurrence of each one.

Thanks in Advance

Use a for loop and inside that you can count the occurrence of each row element in loop in a specific column.

dtYourDatatable.AsEnumerable().Count(Function(row) row("strYourColumnName").ToString.Equals(row.toString))

Thanks a lot @rahulsharma

1 Like

Hello @rahulsharma , Please tell me, How to include row index in for each loop ? Thx

In the for each activity’s property panel. The last option will be index that will store the index for the iteration of for loop

Hello @rahulsharma , Didn’t get what you mean, could you please share that with simple example. Thx

Click on for each activity

In the property panel → the last option will be og Output. in that you’ll see Index field

Create a variable of integer type and assign that variable to that field

This will Store the row number currently in Loop. For first row, the index variables in will have value as 0 and for second it’ll have 1 and so on

Below screenshot shows that last option is Index


1 Like

Hello @rahulsharma
When I declare this variable and use write activity to print all indexed through for each , I got the following error:

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