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:
Read the data from the Excel file.
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.
Write the processed data (filtered customers, total order value, city-wise average) to a new Excel file or a DataTable.
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”)))