Count Number of Occurrences of Keyword in Column, Datatype issue

I’m trying to count the instances of a keyword in a column, but there are different datatypes inherited when I import the data table from Excel.

ColA ColB
1 Keyword
2 Keyword
3 10/05/2020
4 Keyword
5 12345
6 -123.45

In the column, there are strings, dates, doubles, ints, etc. I need to count the occurrences of the Keyword through a formula that can handle these other data types.

I’ve tried the following and the other datatypes are causing issues.

dt.AsEnumerable().Count(Function(row) row.Field(Of String)(“ColB”).ToString.Equals(Keyword))

dt_tempFiltered.Select("[ColB] = ‘Keyword’").Count

1 Like

welcome to the forum

give a try on:
dt.AsEnumerable().Count(Function(row) row("ColB").ToString.Equals(Keyword))



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