I'd like to filter data with a condition

Hello.

1)I’m getting rows with values “ENT960054944L20220922” in column “Key” but I’d like to add criteria to specify the filter and I’d like to get these values BUT with the condition that these rows have values in column “L” (TareaArchivo Contrata) and “N”(Tarea Destino)

In this case, It would filter rows “6” and “36” values of EXCEL.

I have this sentence:

nuevaDT.AsEnumerable.Where(Function(r) r.Item(“KEY”).ToString.Equals(“ENT960054944L20220922”)).CopyToDataTable

Need help with the sentence to filter those two values due to the criteria omitting #N/A .

If there is #N/A in column “L” or “N” , It shouldn’t be considered to be added in the datatable.

Please help and Thanks.

I’m uploading the xaml file and excel that I have.
test1.xlsx (824.5 KB)

Main.xaml (10.4 KB)

@pprin001

Please try like this

nuevaDT.AsEnumerable.Where(Function(r) r.Item(“KEY”).ToString.Equals(“ENT960054944L20220922”) AndAlso Not r.Item(“column6”).ToString.Equals(“#N/A”) AndAlso Not r.Item(“Columnd36”).ToString.Equals(“#N/A”)).CopyToDataTable

Cheers

1 Like

Hi.

I used that but I changed the name of the column6 and 36

nuevaDT.AsEnumerable.Where(Function(r) r.Item(“KEY”).ToString.Equals(“ENT960054944L20220922”) AndAlso Not r.Item(“TAREA ‘Archivo Contrata’”).ToString.Equals(“#N/A”) AndAlso Not r.Item(“Tarea Destino”).ToString.Equals(“#N/A”)).CopyToDataTable

is that ok ?

plus, I run that sentence and It didn’t filter well.

Please.

@pprin001

That looks poper but I donot see NA but it is blank when value is not there so please try like this

nuevaDT.AsEnumerable.Where(Function(r) r.Item(“KEY”).ToString.Equals(“ENT960054944L20220922”) AndAlso Not (IsNothing(r.Item(“ TAREA ‘Archivo Contrata’”)) OrElse String.IsNullOrEmpty(r.Item(“TAREA ‘Archivo Contrata’”).ToString.Trim) OrElse IsNothing(r.Item(“Tarea Destino”)) OrElse String.IsNullOrEmpty(r.Item(“Tarea Destino”).ToString.Trim))).CopyToDataTable

Cheers

1 Like

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