Partial sums in Treetable

Hello, I have checked the documentation that it is possible to do column summaries in a table, the problem is that we have a treetable with a datasource hierarchy and we need to do summaries for each higher level of the hierarchy. For example if we have the following structure:

  • Business
    • Department
      • Section
        • Employee one
        • Employee two

          We would need the summaries in: section, department and company. Any idea to do it ?.
          Greetings and thanks.

A better explanation of the previous question is: the table from which I read the records has the level of detail in sales per employee that I already show in a column in the table, what I need is to summarize this column by hierarchical levels, for example:

Employee Organization Sales

Employee 1 Section 1 100
Employee 2 Section 1 50
Employee 3 Section 2 200
Employee 4 Section 2 150

And the structure that I want to create is the following:

  • Business 500
    • Department 500
      • Section 1 150
        • Employee 1 100
        • Employee 2 50
      • Section 2 350
        • Employee 3 200
        • Employee 4 150

I have tested with the pivot component but I can not figure out how to use it as I need it. In this component I have not seen the concept of measure, only rows and columns, if in the columns I want different values: sales, purchases, etc, places the fields vertically and I would need them horizontally.
Greetings and thanks.


It would be very helpful if you send us a small project wich demonstrates the data model structure because for now, it’s not clear for me and hard to give any pieces of advice. I see two ways: 1. TreeTable with generated column; 2. GroupTable with our without generated column (depends on the data model).


actually I faced the similar problem, I believe - I have a GroupTable and I need to sum up one column (but someone else could be needed more that one, I suppose) partially - i.e. for every group (GroupInfo). As I need only one column to be summed up I’ve just set custom GroupPropertyValueFormatter wich uses custom DataSource method to take label for GroupInfo with counted value. It would be great to find a more convinient solution.

1 Like

I am not sure about TreeTable, but it turned out GroupTable has the ability to calculate partial agregations out-of-the-box. Set aggregatable=“true” and add on columns you need. Killer!

Hello, very good answer LLia, but I have one more question: I created a column calculated with “generateColumn” that simply subtracts the “sales” column from the column “purchases”, I marked them in yellow in the attached image, it would be possible Show this calculation in the upper groupings, which I marked in red?
Thanks and regards.
Attached image.


Hi, I am still trying to show a calculated field in a group of a table, I have checked that partial sums are made at the group level by adding “aggregation” in each column that we want to summarize.
The problem is that if I generate a column with a calculation between two fields of the datasource, this column is shown calculated with its value perfectly, but it is not shown if it is a table group, the summations if it shows them but the calculations do not. A possible solution would be to be able to access the table groups and their summarized values, if you can access these values you could do the calculation and then save the result in the field of the table group. What is not how to access the groups and their fields summarized from the code, any idea how to do ?.
Thanks and regards.


Hi, it seems generated columns couldn’t be aggregated - need to ask CUBA team’s guys. Anyway, you can workaround this problem by adding transient fields in your entities, I believe.