I keep the table that get from Sql Server as a data table.
This data table has ‘expense fields’ and ‘amount’ columns. Is it possible to find the subtotal of each of these expense fields and add them as additional rows to the datatable?
For example;
if this is my data table; (i am show it for instance in excel file but in the reality it is a data table)
i want to find this; (and then i will tranfer it in a excel file)
Its simple when you create a pivot table with the data you have @mazlumkacar . Can you try to pivot out the data and check if that meets your requirement
We can group by and sum up the value of another column
That’s fine
But I m currently thinking like how that can mention in subsequently grouped records as mentioned in yellow colour
You can list the unique “Expense Field” values in the datatable. You can take a datatable list with the size of the number of elements in this list and assign the data in the main table to the relevant datatables according to the field “Expense Field”.
You can then use the Sum formula with Linq to calculate the sum of the “Amount” values. You add the total to the bottom of the table with Add Data Row.
You can merge all tables into one table with Merge Datatable. In this way, a structure is created in the format you want.
can have several options.Can you check if you are transporting empty/Null values? If yes does this error also occurs if you block for Testruns those rows
But take notice of: EXCEL shows . for thousand seperator sign
Your error shows , for this.
The non correct format errors often come from this missmatch
@mazlumkacar
I was thinking for some time on entire flow. Maybe another design is more suitable. I will base my ideas strict on your excel (e.g. Numberformats) and just give me some little time for my alternate idea.
If null values are crashing, then filter those values out as they dont add anything to the sums. Give a try on this
Just do rewire the excel according your environment
for prototyping the result is written in the input Excel under new Worksheet
yellow marking the subtotals ranges is included
give a special attention on numbers and maybe change string/nmber conversions to a more appropriate conversion approach
while developing I focused on balancing maintenace options and number of activities. Thats why I dont tried to put all into single, long and less understandable statements.