Datatable filter copy

Filtering the datatable so i am assigning as getting error.

@Raj_Nadar
convert the cols to string otherwise it is an object equals
r(“GOL”).toString.Equals …
Try EntireDT.AsEnumerable (DataSetExtensions is to reference under the imports

remove the second Where

and often it hangs. so cut the statement inot clipboard. empty the assign expression, reopen and paste the statement

1 Like

if we use enumerable statement getting error… filtering G and R and have the same issue

removeDT.AsEnumerable().Where(Function(r ) r(“RCA”).ToString = “R” and “G”).CopyToDataTable
removeDT.Select("[RCA]=‘R’").CopyToDataTable

not in this form, do it like this
Where r(“GOL”).toString.Equals(“R”) And r(“GOL”).toString.Equals(“A”)

removeDT.AsEnumerable().Where r(“GOL”).ToString.Equals(“R”) And r(“GOL”).ToString.Equals(“A”).CopyToDataTable

Compiler error:

Hy,

You could try the ‘Filter Data Table’ Activity to acomplish what´s on your code.

Regards

Query Syntax:

(From r In YourDataTableVar.AsEnumerable()
Where ("GOL").ToString.Trim.Equals("R") and ("GOL").ToString.Trim.Equals("A")
Select r).CopyToDataTable

Method Syntax

YourDataTableVar.AsEnumerable().Where(Function ( r ) r("GOL").ToString.Trim.Equals("R") and r("GOL").ToString.Trim.Equals("A")).CopyToDataTable

if enumerable blocks then use YourDataTableVar.Select()…

I am reading the datatable and assign and write range in to separate file.
Filter table does not support me hence i am using this assign activity.

filter

see my updated post above

Getting error on assign activity : the source contains no DataRows.

do you have the workflow that you tested, pls share with me.

@Raj_Nadar
Never use a copytodatatable when it is unsure that no rows are returned (Thats the error about)

instead of this do:
YourDataTableVar.AsEnumerable().Where(Function ( r ) r("GOL").ToString.Trim.Equals("R") and r("GOL").ToString.Trim.Equals("A")).toList

And let return a list<DataRow> e.g. drFilterResult Var
then with drFilterResult.Count > 0 you can check if you wantr excute: drFilterResult.CopyToDataTable or
YourDataTableVar.Clone

still i am getting error not sure where it is… if convert to list getting error… will able to help me out.

attached my workflowFLM.xaml (6.7 KB) Testfile.xlsx (11.6 KB)

@Raj_Nadar

The main problem was that your datatype of the drFilteredResult was wrongly set to datarow instead of list(Of DataRow)

find starter help here:
FLM.xaml (7.0 KB)

Kidly note: filtering on Gol=R AND Gol=A will mandatory result into an empty set as GOL cannot be the both for a row. Maybe you will use an OR in case you are interested on Rs and As. But I dont know our requirements.

@ppr - Its not entering with if condition as tried with debugging, have attached one sample file.

Testfile.xlsx (11.6 KB)

@Raj_Nadar

Kidly note: filtering on Gol=R AND Gol=A will mandatory result into an empty set as GOL cannot be the both for a row. Maybe you will use an OR in case you are interested on Rs and As. But I dont know our requirements.

as mentioned: there is no row within the filter result. So there is nothing to enter and the code is running correctly. Change it to the OR operator and then you will get a result from filtering.