I need to keep only the rows where at least one value is above 2.
I wanted to do it with LINQ to make it faster, how can I do this?
I need to keep only the rows where at least one value is above 2.
you need to keep rows where atleast one value is above two. are you comparing all columns valor 1 2 3 4 & 5?
https://docs.uipath.com/activities/docs/filter-data-table
LINQ doesn’t make it faster. The Filter Datatable activity probably uses LINQ anyway.
please try this one
Blockquote
dt_Result = dt_Input.AsEnumerable.Where(Function(row) row(“valor2”).ToString >= “2” or row(“valor3”).ToString >= “2” or row(“valor4” or row(“valor5”).ToString >= “2”).ToString >= “2”).CopyToDataTable
Blockquote
Hi @Gabriel_Wisniewski ,
Instead of deleting rows, we can look at it this way.
Lets focus on the rows that we are interested in retaining.
If you are unsure about the number of columns, and/or its names, or if the rows contain alphanumerical characters, then this might be the solution you are looking for:
Dt.AsEnumerable().Where(Function(w) w.ItemArray.Any(Function(a) If(Integer.TryParse(a.ToString,New Int32),Convert.ToInt32(a),0)>2)).CopyToDataTable()
CheckAllCellsInGivenRow.xaml (7.6 KB)
Kind Regards,
Ashwin A.K
Hello @Gabriel_Wisniewski
You can use Read Range activity and then use Filter Datatable activity. Then you add multiple conditions in the Filter datatable activity. (To remove you can check the Remove field)
Then Use Write Range to write the updated datatable to Excel.
Thanks
I should be comparing the columns (valor1,valor2,valor3,valor4,valor5) to 2. If one or more columns has a value above 2, it will be kept. If no value in those columns is above 2 it should be removed.
Initially I tried the Filter DT activity, but it wasn’t handling null values correctly and for some reason a few values in the “valor” columns weren’t being compared as integers properly.
Then I decided to compare them as string but it got too slow and I had to create too many conditions for my exact purpose.
As I mentioned in another comment above, I was having a few complications with the Filter Data Table activity for this purpose, as I had to create too many conditions and it wasn’t handling null values very well.
In the end this helped me solve the problem, thanks.
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.