How to get the count from the column?

Hi All,
I need to get the count of a column(“Code”), based on the below condition:
if the column contains or start with “992” I dont want to consider in the total count, if the the column name doesn’t contains the “992” then I need to consider the total count.
for example:
if the column “Code” contains: the numbers
99213
88913
90351
99006
from the above values of the column I need to skip the 99213, so the count is 3(88913,90351,99006)

how can I achieve this, please help me.

@ushu
@ppr
@Yoichi
@vishal.kp
@Gokul001
@lakshman
@Chirag_Shetty_Divakar
@jack.chan

Codes

Hi @Vrishchik ,

Maybe you could check with the below Expression :

DT.AsEnumerable.Where(Function(x)Not(x("Code").ToString.StartsWith("992"))).Count

This is datatable column

Hi @Vrishchik ,

use the below expression:

dt.AsEnumerable.Count(function(x) not x(“Code”).ToString.Contains(“992”))

It should not take the count of null or empty.
because it is taking null value also.
instead of 2 it is showing 3

@Vrishchik ,
Updated:

dt.AsEnumerable.Count(function(x) not x(“Code”).ToString.Contains(“992”) and not string.IsNullOrEmpty(x(“Code”).ToString))

@Vrishchik ,

Updated :

DT.AsEnumerable.Where(Function(x)x("Code").ToString.IsNumeric andAlso Not(x("Code").ToString.StartsWith("992"))).Count
1 Like

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