Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Report total from group expression

  1. #1

    Default Report total from group expression

    Is it possible, in PRD 3.0 o 3.5, to make a "report sum" of value that comes from a formula calculation in a group footer?
    Thank you.

  2. #2
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    Well, sums always work over all the rows of a group. So we do sum the stuff we find when the itemband gets printed.

    But: Why dont you simply repeat your calculation with an additional sum that runs over the whole report?

    So lets assume your group contains the formula

    =[Group_SUM_of_A] * [Group_SUM_of_B]

    where Group_SUM_of_A and Group_SUM_of_B are Sum-Functions that have the "field" and "Group" properties defined.

    Then add two new Sum-functions "Report_SUM_of_A" and "Report_SUM_of_B" and only defined the field, and leave the group property empty. Then use the same formula as above, but this time reference the Report_SUM fields/functions.


    If you really need a different calculation schema, then you are always free to implement your own function to do that. But I'm afraid that there is no build in solution for your kind of calculation.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  3. #3

    Default

    I don't have Itemband, I only print "group footer" and "report footer".
    In the "group footer" I make a division (ColumnDivisionExpression) between a TotalGroupSumFunction and a field from db, and then print the result for each group, say Result_1.
    In the "report footer" I need to sum the Result_1 of every group.
    I tried in many different ways but I was not able to obtain this result.
    It seems like that "group footer" band do not pass the value of this division to the "report footer".
    Thank you.

  4. #4
    Join Date
    Mar 2003
    Posts
    8,085

    Default

    You may not *print* anything there, but the reporting engine still has rows that are processed in the itemband stage.

    Change your tactic a bit:

    Lets call the field you sum up "sum-field" and the field you divide by the "div-field".

    Under the assumption that div-field has the same value within each group, we can rewrite your calculation from:

    [sum-field](1) + [sum-field](2) + .. + [sum-field](n)) / [div-field]

    to

    ([sum-field](1) / [div-field]) + ([sum-field](2) / [div-field]) + .. + ([sum-field](n) / [div-field])

    (Or in Mathematicians terms: Just a simple application of the distributivity rule)

    Add a formula (or if you prefer stick with the ColumnDivisionExpression) that sums:

    =[sum-field] / [div-field]
    Lets name the formula "div-sum".

    Now make a Group-Sum or Total-Group-Sum (there is no difference in your case) to sum them for the group and a second group-sum to sum them for the whole report.

    Case solved.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

  5. #5

    Default

    I just did this, like you suggest:
    in a ColumnDivisionExpression, in the group footer band: [sum-field] / [div-field]
    and I put it in a number field, say "div-sum" .
    Now I tried to make the sum for the report(so, first the division then the sum).
    But when I make the TotalGroupSumFunction of the that field ("div-sum") in the report band, I have strange value; anymore, this value is always different every time I run the report.
    So, it seems that the report footer band is not able to take some value from the group footer band.
    Thank you for help me.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.