How to count duplicate value in each column

Hi Guys,

I want below output , please anyone help this

Emp

Regards,
Raja G

Good evening Raja,

I’m not sure what exactly you’re calculating in the “Repeat_Count” column.

Would you mind clarifying what you’re looking for?

Some values appear to get the count of the age for different rows (45 count is 2) and others appear to count the name of other rows (Kartik -> Ross count = 3). It looks very sporadic overall.

Hi @chenderson

Yeah its my manual mistake only, I need just a count of duplicate values and output to show in new column.

Regards,
Raja G

Hey @Raja.G

You will need to create a “pivot table” which gives you the repeat count and then join the data in your input datatable.

The steps are described below:

Create variables:
tempObj - object type
dtDuplicates - 2 column(string type) dt - “CheckDup”
and “Repeat_Count”
dtJoin - 3column(string type) dt - “CheckDup”, “Age”,”Repeat_Count”

Step 1 - populate dtDuplicates

tempObj = dtInput.AsEnumerable.GroupBy(function(x) x(“CheckDup”).ToString).Select(function(y) dtDuplicates.Rows.Add(New Object() {y.Key, y.Count.ToString})).CopyToDatatable

Step 2 - join dtInput with dtDuplicates

tempObj =
(From R In dtInput.AsEnumerable
Join L In dtDuplicates.AsEnumerable
On R(“CheckDup”) Equals L(“CheckDup”)
Select dtJoin.Rows.Add(New Object() {
R(“CheckDup”),
R(“Age”),
L(“Repeat_Count”)
})
).CopyToDatatable

1 Like

Hi @alin.c.mihalea,

Thanks for points , but i didn’t understand below variables , please can u elaborate

Create variables:
tempObj - object type
dtDuplicates - 2 column(string type) dt - “CheckDup”
and “Repeat_Count”
dtJoin - 3column(string type) dt - “CheckDup”, “Age”,”Repeat_Count”

Regards,
Raja G

You have to create those variables in the first place.

Variable name: tempObj
Variable type: Object

Variable name: dtDuplicates, dtJoin
Variable type: datatable

Use Build datatable to add the required columns - as mentioned in the post before.

For Step 2, you may also use Join Datatables activity from UiPath, if you are more comfortable this way.

1 Like

Hi @alin.c.mihalea,

Thanks again, sorry for the update, “Repeat_Count” column just a output column , i need to show the output to next sheet in same excel, because i want more columns duplicate values , can u help this

Regards,
Raja G

If you only follow Step1, a datatable with duplicates will be generated. You can output that wherever you need it.

You can use it for computing duplicates also from other columns.

1 Like