Unable to Filter using Select function on a data table

hi

i am trying to filter my data table using Select function using some conditions , but my out put table is same as my input . What am i doing wrong.

I am trying to extract the rows with total_exp > 4 or a dynamic variable(String)
dtSortOutput - data table variable
Total_Experience - Variable name to filter the table .

Any help would be great.

dtSortOutput.Select(“Convert([Total_Experience],‘System.String’) >= ’ " + Total_Experience.ToString()+” ’ ").CopyToDatatable()

FileName Musthave_Skills Optional_Skills Total_Experience Notice_Period Qualification Location
Testing1 7 4 10 40 0 Chennai
Testing2 6 3 2 30 1 Hyderabad
Testing3 6 6 9 20 2 Noida
Testing4 3 6 6 70 3 Pune
Testing5 3 5 6 35 1 Chennai
Testing6 2 2 4 60 2 Hyderabad
Testing7 15 7 17 20 2 Hyderabad
Testing8 1 1 5 65 0 Banglore
Testing9 1 1 3 25 1 Kochi
Testing10 1 2 6 40 1 Hyderabad
Testing11 0 3 4 45 1 Noida
Testing12 0 3 3 30 2 Banglore

Hi @benjamin.9052

Could you please check out this query once?

int totalExperienceThreshold = 4;

DataRow[] selectedRows = dtSortOutput.Select("Total_Experience > " + totalExperienceThreshold);

DataTable filteredDataTable = dtSortOutput.Clone();
foreach (DataRow row in selectedRows)
{
    filteredDataTable.ImportRow(row);
}

Hope this helps,
Best Regards.

keep in mind that with this forced to string logic a lexically compare is done. Here it will have wrong evaluations:

grafik

One of many options could be the usage of a LINQ
Assign Activity
dtFiltered =

(From d in dtSortOutput.AsEnumerable()
Where CInt(d("Total_Experience").toString.Trim) >= YourIntVar
Select r = d).CopytoDatable

Handling empty results
:ambulance: :sos: [FirstAid] Handling of The source contains no DataRows exception - News / Tutorials - UiPath Community Forum

Thank you for your help @ppr and @arjunshenoy

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