Hi there, I use filter datatable to remove rows I don’t need.
but always can’t get the result.
I need final data contains ORG A and B, request date less than 2021-01-01, and COMP_STAT is not Unbooked. Main.xaml (9.9 KB) File1.xlsx (20.6 KB)
@learningRPA Check this workflow :
FilterDT.zip (13.0 KB)
I used Linq queries to get the required output, as I don’t think the date Comparison works well with Filter Datatable.
HI Arpan, thank you so much! But I need rows NOT equal unbooked, how to change this criterial? and can you explain this whole flow, I’m a beginner, and a little hard to understand it. Thank you again!
@learningRPA Ohh Sorry. There is a Minor change that you need to do in the Linq Query in the First Assign Activity. You would need to add a NOT as shown below :
Let me know if it doesn’t work.
Introduction to Linq and it’s operations and it’s uses might be useful for future references to Linq :
@learningRPA The Explanation goes as follows :
-
The First Assign Activity is a Linq query which filters the Datatable based on the Criteria mentioned in it. The Criteria can be easily analysed. However, the Result is an Array of Data rows. So the Varialbe used for the assign is of the same type.
-
The Resulting array of datarows is checked if there exists any row in it using an If Condition Activity.
If it exists, then the data rows are converted to datatable, as the output you need should be in the form of a datatable. If there exists no rows, that would mean the filter condition resulted in no rows, Hence we are initialising the datatable to it’s clone to just keep the headers of the datatable. -
As you have a constant date to filter, we first need to convert that date value into a Date Time type. That’s the assign with DateTime.ParseExact() method, which converts the String date to DateTime. This resultant date is next used to compare dates in the filtered datatable result from the previous query.
-
The next assign is the same operation as in the first query but the filter criteria is different as we are performing the Less than the Required Date operation in it. After that similar operation to check if the rows are present and assignment of data rows to the datatable is done.
Let me know if you have more doubts.
You can also do the First filter using the Filter Datatable Activities, as I had already implemented in Linq, I continued with it.
But the date filter I think you should do it with a Linq query as I have provided, since there might be mismatch in date comparisons using Filter Datatable
Hi Arpan, it works! Thank you!
I think this is another way.
Main (2).xaml (12.0 KB)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.