Need to find the count from Datatable

Hi ,

I’m extract the data from data scrapping now i want to have count of duplicate name. Please share your view below is the example:-

ID Name
1 AA
2 AA
3 AA
4 QQ
5 QQ
Now i need the count of AA and QQ separately.
2 Likes

Hello @Dany069

you can try this
Dim name as integer
For each row As DataRow In "dt_ScrappingOutput’

name = row(“Name”).tostring.count

next row

Or if you have the value in a variable of type string, try this:

dim count as integer = yourString.count

1 Like

Hi @Dany069

These two should work:

yourDataTable.Select("[Name]='AA'").Count

and

yourDataTable.Select("[Name]='QQ'").Count

These queries will count the occurrences of either AA or QQ. To get the count of just the duplicates, you can subtract 1 from the query result :slight_smile:

6 Likes

Hi,
I have used but giving error because the column name in array do i need to convert this into string row.item(columnname).

Could you post a screenshot of the exact error and of your workflow?

Please find the attached screenshotPing

Thank you. Could you add to that a screenshort of the the full syntax in your workflow?

Ping1

This expression can be used in an Assign activity and not in a loop. For example, try this in a Log Message activity:

yourDataTable.Select("[Name]='QQ'").Count.ToString

It should print the count into the console :slight_smile:

Hi

you can use the group by aggregation activity in the below one.

Regards
Balamurugan.S

hi there, what will the syntax be if we are trying to get a count of a certain string rather than an exact match? for eg. in above scenario, if values are ‘AA’ or ‘QQ’, we will get the count. What if we even want the count of AA if it is part of a string (eg.‘AABB’)?
Thanks in advance

Hi @mchadha

Please see this comment :slight_smile:

@loginerror - thank you so much for the quick response. Works fine now :smile:

1 Like

Trying to implement this, but the Select is not working or should I say, always returns a Count of 0 (zero)…? Any ideas as to why?

image

image

Try outputting the underlying data table to your Output panel (Output Data Table activity) or simply save it into Excel. This should give you a clue on what is going wrong there.