I wish to group the data table by Expense category and Sum up the Cost.
Travelling - 1139
Food - 50
are the any means to group by Expense category and Sum up the Cost using DataTable.Select()?
dtResults = (From dte In dtTable.AsEnumerable
Group dte By col1=dte(“expense category”).ToString.Trim Into Group
Select dtResults.Rows.Add({col1, Group.Sum(Function (x) Cdbl(x(“cost”).toString.Replace(“$”,””).Trim))})).CopyToDataTable
Dtresults is the final result use in assign on left and remaining on right
dtTable is the input datatable
Change the column names to exactly match your datatable
(From dte In ExpenseTable.AsEnumerable
Group dte By col1=dte(“Expense category”).ToString.Trim Into Group
Select ExpenseTableProcessed.Rows.Add({col1, Group.Sum(Function (x) CDbl(x(“Cost”).toString.Replace(“$”,””).Trim))})).CopyToDataTable
(From dte In ExpenseTable.AsEnumerable
Group dte By col1=dte(“Expense category”).ToString.Trim Into Group
Select ExpenseTableProcessed.Rows.Add({col1, Group.Sum(Function (x) if(IsNumeric(x(“Cost”).toString.Replace(“$”,””).Trim) ,CDbl(x(“Cost”).toString.Replace(“$”,””).Trim,0)))})).CopyToDataTable