How to do sum of column(Total profit) by Region in excel file

Give a try on

  • Build datatable Activity | 2 Cols: Region, Total Profit | Varname: dtReport

  • Assign Acitvity
    left side: dtReport
    right side:

(From d in YourDataTableVar.AsEnumerable
Group d by k=d(“Region”).toString.Trim into grp=Group
Let st = grp.Sum(Function (x) CDbl(x(Total Profit).toString.Trim)
Let ra = new Object(){k, st}
Select r = dtTarget.Rows.Add(ra)).CopyToDataTable

Depending on how the Total Profit Values are read in from Excel maybe we have to adopt this part accordingly

Also have a look here:

1 Like