Great a subtotal in Excel

I have read an Excel file and would like a subtotal for each “Geschäftszeichen”.

Can you give me a tip on how I can do this?

Assign - strSum= dtMyDataTable.Compute(“SUM(ColumnName)”, “”).ToString

The second parameter, which I’ve denoted as “”, is a filter.
You can filter with the unique values and proceed the sum

Mark as solution if it helped.

In general we can achieve it by grouping the data

here we can construct a datatable or a lookup dictionary

parsing the amount


myLKDict | Dictionary (Of String, String) =

(From d in YourDataTableVar.AsEnumerable
Group d by k=d(0).toString.Trim into grp= Group
Let ts = grp.Sum(Function (g) Double.Parse(g(1).toString.Trim System.Globalization.NumberStyles.Any, new System.Globalization.CultureInfo("de-AT")))
Let tsf = ts.ToString("C2", new System.Globalization.CultureInfo("de-DE"))
Select t = Tuple.Create(k,tsf).ToDictionary(Function (t) t.Item1,Function (t) t.Item2)

then with myLKDict(“115300”) the subtotal for the G-Zeichen will be returned

@nina.wenner Try getting the unique value by this

dt1.AsEnumerable.Select (Function (r) r (“columnname”).ToString.Trim).Distinct.ToArray

Once you get the unique values, you can filter with each value and find the sum