Get count of specific row in data table

I have two Excel sheets. The data of one column of excel1 is matched with the data of column of another excel2. If the match is successful the count of the row matched in excel2 should be displayed.
How do I get that count ??

In general use datatablevar.rows.count
But i suggest to count the Matching rows e.g with a join
You can use for this
Join Datatable Activity or a linq statement

1 Like

DataTable1.Rows.Count.ToString
DataTable2.Rows.Count.ToString

you can check like this

@AditiGandhi
Have a counter variable when entering into the loop for checking the matches.
this is will give the no of rows is matched.

Hello Aditi,
To get count of items in row,please check following WF,

@Pradeep_Shiv, Not the count of all rows. I want the count of row which is matched

@AditiGandhi
Please refer the xaml file.

test.xaml (10.8 KB)

Happy Automation :slight_smile:

Using a nested loop has the risk, that the matching rows cannot be found due the matching rows are not in sequence. This can be overcome with a clean join between both tables.

the most simplest statetement for the matching count could look like:

(From d1 In datatableVar1.AsEnumerable
Join d2 In datatableVar2.AsEnumerable
On d1(YourJoiningColNameOrIndex) Equals d2(YourJoiningColNameOrIndex)
Select d1).ToList.Count

can be used within an assign and will return the count of matching rows

Or using Join DataTable - Example:

and dtCombined.Rows.Count

@AditiGandhi

You can also check this solution,

Cheers!