Categories > TinyButStrong general >

subtotal example ?

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: fernando
Date: 2010-11-09
Time: 15:37

subtotal example ?

i have this array:

A xxx xxx 10 20 30
A xxx xxx 20 30 40
B xxx xxx 20 30 40
B xxx xxx 20 30 40
B xxx xxx 20 30 40
C xxx xxx 20 30 40
C xxx xxx 20 30 40

i try to find what is the best way to get subtotals like this:

A xxx xxx 10 20 30
A xxx xxx 20 30 40
   ==> subA 30 50 70
B xxx xxx 20 30 40
B xxx xxx 20 30 40
B xxx xxx 20 30 40
   ==> subB 30 50 70
C xxx xxx 20 30 40
C xxx xxx 20 30 40
   ==> subC 40 60 80

i want groupping by A,B and C and sum the last 3 fields

thanks!
By: Skrol29
Date: 2010-11-09
Time: 16:58

Re: subtotal example ?

Hi,

TBS has a grouping feature in native. In your case it can only do the footer line under each subgroup ( A, B, C), but it cannot to the totals.
There is an aggregate plug-in, but it doesn't work with the grouping feature, i.e. it cannot do the total of sub-groups.
But you can use a custom function to calculate the cumulative totals in a new column ; and then display this column in the footer section.
Such a calculation can be done with an "ondata" parameter.

See: http://www.tinybutstrong.com/manual.php#html_block_prm_ondata