Adding a row with summation in numeric columns with a row that has the same key column value.

It is easiest to explain with a real example.

There are "Board" objects. These objects have the field "standard size" ("100x40", "50x40", etc.), "unit" ("linm", "sq.m", "cub.m") and "quantity" .

We want to get a summary table, where all the objects of the "Board" type in the project are summed up as follows:


Материал

Unit

Count

Board 100х50

m

1000

Board 50х40

m3

2000

Board 50х20

m2

1900


To do this, we create a table with one key column and columns for regular data.

ts_table(TableDescr1,"add_column",0,"string","object name + type + unit");

ts_table("TableDescr, "set_first_key",0);

ts_table(TableDescr1,"add_column", 1,"string","objectname");

ts_table(TableDescr1,"add_column", 2,"string","tiposize");

ts_table(TableDescr1,"add_column", 3,"string","edizm");

ts_table(TableDescr1,"add_column", 4,"double","kolvo");

ts_table(TableDescr1,"set_columns_to_add_sum", "kolvo");


To add a row to a table, simply use the following entry:

ts_table(TableDescr1,"add_row_sum",0,objectname+tiporazmer+edizm, 1,objectname, 2, tiposize, 3, edizm, 4, kolvo);

As a result, all objects in the table with the same value name+type+unit. will be reduced to single records, and the column "quantity" will contain the amount количеств.