Filter Data table using LINQ

Hi Expert,

I have an excel file and want to file the status column and get only “No” status in other sheet. How can achieve this by LINQ. attached input file
Fil-Input.xlsx (9.1 KB)

Regards,
Balachander P

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

@Balachander_Pandian

Easiest would be to use a filter datatable and filter the column for No

if you need linq then use this in assign

requireddt= dt.AsEnumerable.Where(function(x) x("ColumnName").ToString.Tolower.Equals("no")).CopyToDatatable

after any of the above two steps use write range and write to different sheet

cheers

Hi @Balachander_Pandian

syntax : DT.AsEnumerable.Where(Function(r) r(“Status”).ToString.Equals(“No”)).CopyToDataTable

Can use this.

@Balachander_Pandian

dt1.AsEnumerable.Where(function(row) row(“Status”).ToString.ToLower.Equals(“no”)).CopyToDataTable

@Balachander_Pandian

DT=(From row In DT.AsEnumerable()
Where row(“Status”).ToString() = “No”
Select row).CopyToDataTable()

image

Hope this hepls

Hi @Balachander_Pandian

Try this:

yourDataTable = (From row In yourDataTable.AsEnumerable()
                Where row.Field(Of String)("Status") = "No"
                Select row).CopyToDataTable

Hope it helps!!