Filter Data Table does not work

Hello,

I want to filter the following Data Table for values smaller then 600.

The filter ist set up like this:

However in the unfiltered list are 20 values and in the filtered list as well.

Has anybody an idea what i am doing wrong?

Hi @VLC

Use the below LINQ Expression in Assign activity,

- Assign -> dt_Output = dt_Input.asenumerable.where(Function(X) Cdec(X("Nettowert").toString.replace(",",""))<600).Copytodatatable()

Hope it helps!!

1 Like

@VLC,

It could happen due to datatype difference in column and 600.

Use assign activity to filter it using LINQ like below.

filteredDataTable = (From row In inputDataTable.AsEnumerable() 
                             Where IsNumeric(row("Nettowert").ToString()) AndAlso Convert.ToDouble(row("Nettowert").ToString().Replace(",", ".")) < 600 
                             Select row).CopyToDataTable()
2 Likes

Your column is probably string, not float.

Assumption:
Value is string and using the German Number format: , is decimal Seperator

So we would convert the string by applying the german number format like this

and can incorporate it within the following LINQ:
Assign Activity:
dtFiltered | DataType: DataTable =

(From d in YourDataTableVar.AsEnumerable
Let vs = d("Nettowert").toString.Trim
Let vp = Double.Parse(vs , System.Globalization.CultureInfo.CreateSpecificCulture("de-DE"))
Where vp < 600
Select r = d).CopyToDataTable

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

Starter Help for LINQ:
[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

Kindly note:
weil von kleiner 600 die Rede war, haben wir die Bedingung Where vp < 600 gewählt
In den Screenshots war aber das Entfernen der Zeilen von < 600 gewählt
ggf. muss das Filterkriterum angepasst werden, mit einem > 600 oder einem Not, um es zu verneinen

1 Like

Hi guys, thank you all for the input. You were defintly right. The issue was the formating with the german thausands seperator.

I have found an easy solution in UI Path. You can define how the numbers should be read.

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