US and Worldwide: +1 (866) 660-7555
Results 1 to 2 of 2

Thread: Average aggregation

  1. #1
    Join Date
    Feb 2012
    Posts
    10

    Default Average aggregation

    Hello, I'm using Report Designer 3.8.3.
    i have data with groups like this:

    QUANTITY | COST | UNIT COST
    ----------------------------------
    1 | 16,05 | 16,05
    3 | 347,10 | 115,70
    3 | 1647,12 | 549,04
    ----------------------------------
    7 | 2010,27 | X

    where X is the average value, set in the group footer. I'm setting the value as =SUM(COST)/SUM(QUANTITY). So, in this example, X should be 287,18 but what I get instead is 549,04, so it's considering just the last values (1647,12 / 3) instead of the sums. What am I doing wrong?
    Last edited by tiagoversuti; 06-13-2012 at 09:09 AM.

  2. #2
    Join Date
    Mar 2003
    Posts
    7,560

    Default

    If "SUM(...)" refers to a formula function, then that wont work. Formulas can only access the current state, not previous rows.

    To get a sum, add a "Running Sum" or a "Total Sum" function to your report, give it a name and then reference these functions in your formula.
    Get the latest news and tips and tricks for Pentaho Reporting at the Pentaho Reporting Blog.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •