How to use LINQ Query to develop a task in UiPath studio

Hi Everyone,

I would like to ask a question on LINQ Query, I want to develop a UiPath workflow that extracts data from an Excel file, manipulates it using LINQ, and writes the processed data to a new Excel file or another target (e.g., Data Table).

Scenario-

I have an Excel file containing customer data (ID, Name, Email, Order Amount, City). The task is to:

  1. Read the data from the Excel file.
  2. Use LINQ to:
  • Filter customers who have placed an order exceeding a specific amount (provided as an input variable).
  • Calculate the total order value for all customers.
  • Group customers by city and find the average order value for each city.
  1. Write the processed data (filtered customers, total order value, city-wise average) to a new Excel file or a DataTable.

I would appreciate a prompt reply !!

Thank you very much in anticipation.

Regards,
TIN RPA

@TIN_RPA,

Try to specify issue you are facing.

Thanks,
Ashok :slight_smile:

Have a Look at the basics for

Hi @ashokkarale,

  • Filter customers who have placed an order exceeding a specific amount (provided as an input variable)- got this by using Linq query - (From row In Table_DT.AsEnumerable()Where Convert.ToInt32(row(“Order Amount”)) > SpecficAmount Select row).CopyToDataTable

  • Calculate the total order value for all customers- Got this by using- (From row In Table_DT.AsEnumerable() Select Convert.ToInt32(row(“Order Amount”))).Sum()

  • Group customers by city and find the average order value for each city- not getting this by using- CityGroups_En As IEnumerable(Of CityOrderInfo) = From row In FilteredCustomers_DT.AsEnumerable() Group row By city = row.Field(Of String)(“City”) Into Group Select New CityOrderInfo With {.City = city, .AverageOrderValue = Group.Average(Function(r) Convert.ToInt32(r.Field(Of Integer)(“Order Amount”)))

Plesae help me on this where I am doing wrong.

Thanks