Filtering Data Table Activity

Hello,

I am attempting to filter a data table; however, I know that integers are not able to be used. Looking through previous conversations, I have found a select statement and made it fit my data:

apbatchesws.AsEnumerable.Where(Function(r) If(IsNumeric(r(“BCHSTTUS”).ToString.Trim), Convert.ToInt32(r(“BCHSTTUS”).ToString.Trim) > 0, True).ToArray

However, after putting it into the Value side of the Filter Wizard, I am getting an error. Am I using this incorrectly?

Bad question, I know.

Hi @Sara_Car
i think we can mention the integer value in filter datatable activity, by mentioning them without double quotes, i.e., like integers
can i have a view on your filter datatable activity wizard once
Cheers @Sara_Car

@Sara_Car

It is LINQ query to filter dataTable. Don’t use this expression inside Filter dataTable Activity.

@Palaniyappan Yes, I have tried this and it returns 0 to me when I know that it should be 3.

image

1 Like

your excel screenshot please buddy @Sara_Car

Fine mention the value for “Company Name” as “presentcompany”
not as presentcompany
i think it didn’t detect that value thats why giving as 0 output
Cheers @Sara_Car

Buddy
i have a doubt is presentcompany is a variable or a value
if its a variable then fine with what you want have mentiond
or
if its a value it must be within double quotes
Cheers @Sara_Car

I have presentcompany set as a variable that I am hard coding currently for testing purposes. Otherwise this would not be there.

Here is my excel: image

This is sensitive information, so I did remove some data

well do the column BACHNUMB has any value in it like starting with “WS”
because i dont find such out here
make sure you have all the conditions between AND in the filter datatable wizard, so all the condition must satisfy, kindly check with buddy

Cheers @Sara_Car

Yes, I’m wanting that column to only get rows that start with WS for the BACHNUMB column. Then I must only get the zero rows under the BCHSTTUS column. This is where my issue originates. The filter wizard is not accepting my integar value.

This is where I must seek guidance.

1 Like

or you can even mention as a string “0”
within quotes
Cheers @Sara_Car

sorry for the last comment,
dont take it
@Sara_Car

Fine try with this condition buddy
a select method would work
yourdatatable = yourdataTable.Select(“Convert([BCHSTTUS],‘System.Int32’)>0 AND [Company Name]=‘“+presentcompay.ToString()+”’ AND [BACHNUMB] like ‘WS’ " ).Copytodatatable()

Cheers @Sara_Car

1 Like

@Palaniyappan thank you so much! However, I am getting an error

1 Like

yourdataTable.Select(“Convert([BCHSTTUS],‘System.Int32’)>‘0’ AND [Company Name]=’“+presentcompay.ToString()+”’ AND [BACHNUMB] like ‘WS’ " ).Copytodatatable()

1 Like

Hi @Sara_Car

Try to give Convert([Company Name],System.String=‘"+presentcompay.ToString+’"

Thanks
Ashwin S

1 Like

@Palaniyappan shouldn’t something come after the Convert? I believe this is where my error might be coming from, but I am not sure. As you know, I am not proficient at this language.

@AshwinS2 can you explain this for me? I want to understand this convert. Wouldn’t I be solely converting a column that I already have no issue with?

1 Like

Sorry buddy typo mistake @Sara_Car

yourdataTable.Select(“Convert([BCHSTTUS],System.Int32)>‘0’ AND [Company Name]=’“+presentcompay.ToString()+”’ AND [BACHNUMB] like ‘WS’ " ).Copytodatatable()

Cheers

1 Like

Hi @sara

Is the error coming or not ?? :slight_smile:

Convert is where we need to ensure whether the column value might have numeric values or not to ensuire we need to give Convert[“Column Name”],System.String

Is the clarification clear @Sara_Car buddy

Thanks
Ashwin S

1 Like

As we discussed earlier, we need to convert the column value to integer
So usually converting a type to another type is called as casting…
Here we are trying to cast the whole column rather than a value in it…
The convert method takes argument like
Convert.datatypeyouwanttochange(“thevalue”)
For example
Convert.ToInt32(“124”)

Or

Convert(“thevalue”,“datatypeyouwanttochange”)
Like how we have done now…
Where system.Int32
Means.
System is a namespace and int32 is a class in it, thus converting the column of type string to integer

Hope this would help you buddy
Cheers @Sara_Car

1 Like