Problem Filter Data Table not working

Hi, I would like to generate a new table from an existing table that has to be filtered as follows, but these filters do not work. What am I doing wrong?
Filter

Hi @NHoe

Do you get any errors?

And what is the variable afteesnummer contains?

Thanks

I do not receive any errors, the order number occurs several times in the original file, the new table should contain all rows that belong to the order number with the corresponding filters.

@NHoe if you do the filtering manually do you have results coming in the excel?

Put a message box before filter datatable and check the value of the variable actrnummber of its comming correctly.

Thanks

I have checked that, it fits. As I said, the “Auftragsnummer” appears several times in column A, but has entries in the other columns under which it cannot be included in the new file. My goal is to transfer all order numbers into a new file if the filter criteria are met, but this does not work, it transfers all “Auftragnsummer” without the other filter criteria.
Filter2

You have Build Data Table and then Add Data after the Filter Data Table. This is unnecessary and causes the filtering to be overwritten. Filter Data Table creates the new datatable for you automatically. Don’t create it again, this wipes it out. After Filter Data Table, your filteredDT contains just the data you wanted.

have a check on Auftragsnummer that not numeric-string compairs disturb the result. As an alternate give try on LINQ, allowing you additional control

Assign acitity
left: dtFiltered

right:

(From d in inputDT.AsEnumerable
Where d("Belegnummer").toString.Trim.Equals(Auftragsnummer.toString)
Where Not d("Streckengeschäft").toString.Trim.ToUpper.Equals("X")
Where d("Auftragsart").toString.Trim.ToUpper.Equals("AUFTRAGSART")
Where d("Beleg auf HALT").toString.Trim.ToUpper.Equals("N")
Select r=d).CopyToDataTable

We do not know the datatype of Auftragsnummer, check if tostring is unneded when already string datatype

2 Likes

Hi

I can see in the image like you are using the filter datatable inside a for each row loop

Don’t use loop here if you are just trying to filter the datatable

Use directly the filter datatable with your current conditions after getting the dt variable from read range

Cheers @NHoe

the Variable type of Auftragnummer is Uipath.Core.GenericValue, is this the problem?

Please try the LINQ, should work(werden wir dann sehen :slight_smile: )

I have tried to implement it without the for each loop, but I fail. The decisive factor is the “Auftragsnummer”, I would like to have the data for each “order number” that occurs several times in the original file in a separate file and name the new file with the “Auftragsnummer”.xslx.

@NHoe

sounds like grouping data

(From d in YourDataTable.AsEnumerable
Group d by k=d(“Auftragsnummer”).toString.Trim into grp=Group
Where grp.Count > 1
Select g=grp.CopyToDataTable).toList

it will group all rows with same ANummern when group count > 1 into a seperate datatable.
The return is alist of datatable, each datatable will contain the rows from one group

Thank you for the tip, I have read it through, but I don’t know what to do with it.

I want to read in the master file and create individual files from it, depending on the “order number” and the other filters. The new files should have the order number as the file name. Unfortunately, the following solution does not work. Main.xaml (39.6 KB)

OK will have Look on IT once im back from travelling

Thank you!


Main_V2.xaml (10.1 KB)

as far we had understood

Hi Peter, thank you very much for your xaml. Basically it is exactly what I wanted to achieve, but the filters do not work properly.

“Where Not d(“Drop Shipment”).toString.Trim.ToUpper.Equals(“x”)
Where d(“order type”).toString.Trim.ToUpper.Equals(“normal order”)
Where d(“document on HALT”).toString.Trim.ToUpper.Equals(“N”)”

I still get results in the new files even though the filters should exclude them, what could this be?

I have it, Thank you!

(From d In inputDT.AsEnumerable
Where Not d(“Streckengeschäft”).toString=“x”
Where d(“Auftragsart”).toString =“Auftrag”
Where d(“Beleg auf HALT”).toString=“N”
Group d By k=d(“Belegnummer”).toString.Trim Into grp=Group
Select g=grp.CopyToDataTable).toList

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