How do you compare a variable with the column item in a data table?

I am trying to filter out rows from a data table where the Order_ID is NOT EQUAL to an Order ID extracted from a PDF document which I will be storing in a string variable eg. “OrderID”.

I have tried everyway to do this with the Filter Data Table, however it just keeps making a partial match and then returning rows even where a few characters match the “OrderID” variable, if someone could recommend a way of doing this using the Filter Data Table that would be much appreciated.

However I have managed to do this with Remove Data Row, however I cannot select into “filteredList” (Array of Data Rows), based on “OrderID”.

Please see workflow. I need to change:

transactionsDT.Select(“Order_ID <> ‘CLS-178-4486’”)

the text ‘CLS-178-4486’ is the Order ID which is supposed to be a variable “OrderID”, how would I write this?, what is the syntax?, I am really baffled something this simple looking is taking all day.

Main.xaml (6.4 KB)

@Taariq

Try like this:

    transactionsDT.Select(“[Order_ID] <> ‘CLS-178-4486’”)

It will give all rows which are not equal to that Order ID.

2 Likes

transactionsDT.Select(“Order_ID <> ‘" + varOrderID + "’”)

Regards,
Karthik Byggari

2 Likes

Hi Lakshman the ‘CLS-178-4486’ needs to be a variable for the purposes of the work assignment, it is the OrderID read from a pdf document. It cannot be quoted text.

@KarthikByggari it gives an error when run (see screenshot attached), please refer to full workflow attached, it needs to:

  1. scan the PDF document and save the variable text to variable,
  2. then extract the OrderID which is a variable,
  3. based on this OrderID it needs to go into excel order file and filter out all rows which do not pertain to that order.
    Main.xaml (9.9 KB) project.json (759 Bytes)

Can you paste the expression here to check.
Syntax is wrong.

1 Like

@KarthikByggari expression: filteredList = transactionsDT.Select(“Order_ID <> ‘" + OrderID + "’”)

filteredList - is array of datarows to be filtered out using ‘remove data row’
transactionsDT - is the Data Table read from excel
OrderID - is the order id read from pdf stored as text
Order_ID - is column in the data table read from excel

@lakshman @KarthikByggari here is the excel file
Transactions.xlsx (340.8 KB)

1 Like

Hi @Taariq,

I understand that you want to maintain the rows where the column Order_ID are matching with the OrderID. I used your excel file, and its working with a Filter Data Table (If its the opposite case, its working too). Here you have the workflowMain.xaml (7.7 KB) . Maybe the problem is the OrderID extracted from a PDF. Could you upload the PDF?

1 Like

@marherfer hi m yes this is correct, please refer pdf attached
Balance_Request.pdf (267.3 KB)

@marherfer however I would also like to know what is the correct syntax to script a variable where it needs to be contained within " " marks? I have searched through the UI Path documentation yet there is no mention of this.

Here you have, I hope its useful. Main.xaml (11.5 KB)

1 Like

This expresion is working to me: Main (1).xaml (9.3 KB)

1 Like

@marherfer @KarthikByggari @lakshman thank you all the problem was that it was a generic value which needed to be converted to string first the syntax used in the expression:
transactionsDT.Select(“Order_ID <> ‘" + varOrderID + "’”) was correct. It works fine with Filter Data Table or Remove Data Row now. Thanks a lot!

2 Likes