Hi there, I’m relatively new to UiPath. I have some excel files in which I’m trying to use the Select method to store the data of the Subtotal, GST, and Total into respective variables. Please see below a sample of the excel file:-
Using the Assign activity, I tried using the Select method in extracting the Subtotal, GST, and Total from the table using the following:-
Subtotal = tableDT.Select(“PRICE = 'Sub Total '”)(0)(“TOTAL”).ToString
GST = tableDT.Select(“PRICE = 'GST 8% '”)(0)(“TOTAL”).ToString
Total = tableDT.Select(“PRICE = 'Total '”)(0)(“TOTAL”).ToString
@schee013 The error might be due to the data type of the column being different than a String type as you are trying to Match a String value in that Column. You can maybe convert the The Column Value to String and then match it with a String Value and check if it works, a similar conversion is given in the post below :
@schee013
give a try on forcing the conversion like:
Subtotal = tableDT.Select(“Convert(PRICE, ‘System.String’) = 'Sub Total '”)(0)(“TOTAL”).ToString
An alternate Approach would be LINQ
(From d in tableDT.AsEnumerable
Where d(“PRICE”).ToString.Trim.Equals(“Sub Total”)
Select s = d(“TOTAL”).ToString).Single()
the Single() method throws an exception in case of not 1 only value is retrieved. So it can be used for result checking