String item

Hi, as shown in the Excel file. I need to know which country has the most occurrences in “Country” column as I need to find out which country has the most players represented. I also need to show my output using “Message Box” as requested.

E.g. The message box will show
The country that has the most players is Argentina.

What & how should I do?

Please kindly help!! Greatly appreciated.

Hi @rubyyy
Read the excel and use this code
dt.AsEnumerable.GroupBy(Function(r) r(“ColumnName”).ToString).OrderBy(Function(g) g.Count).Last().First().Item(“ColumnName”).ToString

COUNT – To count the number of cells that have numbers in it.
COUNTA – To count the number of cells that are not empty.
COUNTBLANK – To count blank cells.
COUNTIF/COUNTIFS – To count cells when the specified criteria are met.

Hope This Helps,
Peter

Hi @sangeethaneelavannan1
Thanks for your reply, as I just started to use UiPath
May I know where should I apply this code at? Or Should I use it at which component?

Hi @Peter_Groft

Thanks for your help & reply!

But how can I use the count for my case?

@rubyyy
Read range workbook activity -To read the excel data and convert it to datatable
Using Assign activity output dt=the above code
Using write range workbook activity to write it in excel

1 Like

Hello @rubyyy

Welcome to UiPath community…!

You can do as below.

DT2.AsEnumerable.GroupBy(Function(r) r("Country").ToString).OrderBy(Function(g) g.Count).Last().First().Item("Country").ToString

DT2 is the output of Read range workbook activity.

Count is a String variable.

image

Thanks

Hi @Rahul_Unnikrishnan

Thanks!

Do you know how can I solve this?

image

“dt_countmax” should be a string variable and “dt” should be a datatable variable.

Also if you have copied the expression from this post, please remove the double quotes and reenter.

Thanks

@rubyyy

For the Read Range activity, you need to create an output “datatable variable”. Just consider you are creating “DT2”.

Then expression will be as below.

DT2.AsEnumerable.GroupBy(Function(r) r("Country").ToString).OrderBy(Function(g) g.Count).Last().First().Item("Country").ToString

Thanks

I still receiving the same error, not sure which part it I did wrong


check my previous post.

Also in your workflow why you have used the for loop?

If you are using this expression, then you can delete that part. After extracting the data from webpage, you that datatable variable directly in the expression.

Thanks

Hi @Rahul_Unnikrishnan

Thanks a lot for your help! The solution is working now.

Now that I know the most players from which country if I want to know the number of most players from that specific country, what should I do?

E.g., The country that has the most players is Argentina, The number of players: 19.

Please kindly help, greatly appreciated your assistance!!!

Hi all

Now that I know the most players from which country if I want to know the number of most players from that specific country, what should I do?

E.g., The country that has the most players is Argentina, The number of players: 19.

Please kindly help, greatly appreciated your assistance!!!

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