Count number of occurences of keyword in data table

I’m having a couple of issues while trying to count the number of times a keyword shows in a data table.

Initially, I’m looping through a datatable to get the initial count - that works fine. Using the same dt, I’d like to count the number of times a keyword shows within a specific column.
(The column name has been defined within the ‘Get row item’ read from an excel doc)

I’ve tried to set this condition within an if statement:

(Convert.ToString(row.Item(“Column Name”)) = “My Keyword”=True)

Then attempt to get the count of those rows which meet that condition however, I receive this error: Object reference not set to an instance of an object.

I’ve also tried a select statement, but again I’m receiving errors. Can someone point out if I’m missing something / a simpler way to achieve this?


You can remove “=True” from your condition. Also the error you received might mean you used a variable that’s empty. Do you have the If condition inside a ForEach row loop? That way row has data.

Hope that helps a little.


Hello @qwerty1,

You can use a select statement to count the number of occurences of a keyword, here is an example:

Keyword.xaml (7.8 KB)



Thanks, I no longer receive the error message any longer, but I’m still not able to get the total count.
No error is thrown, but it doesn’t seem to meet the condition when I step through in debug mode.

Thank you for providing the example!
I can now ‘see’ it clearer in my head & know how to apply it to my own workflow.

Thanks again!

How to count the number of occurrences of a keyword in excel

I want the result to be printed into an another excel sheet as

Name Count
Praveen 3
Karthick 2
Pragadee 1

Bt the Names can be dynamically changed