Jump to content
Changes to the Jaspersoft community edition download ×

sum for repeated value.

2005 IR Help

Recommended Posts

By: lgwheat - lgwheat

sum for repeated value.

2004-03-16 09:17

In my result set, I have a numeric value that remains constant for all rows within a given group. I want to add this value to a sum (just ONCE - vs for every row in which it occurs) and display the total later in the report. Any advice?









By: Tobias Gaekle - ike987

RE: sum for repeated value.

2004-03-16 09:38

if the numeric value is avaiable in every row as a field, then you can define a variable something like this:


<variable name="once_added_sum" evaluationTime="Now" class="java.lang.Float">


new Float($V{your_sum}.floatValue() + $F{numeric_value_field}.floatValue())




you can also save your numeric value in a variable that reinitialises when the group changes, in case it's not available as a field in every row.





By: lgwheat - lgwheat

RE: sum for repeated value.

2004-03-16 13:00

Sorry, I?m confused more about the order of evaluation of things. I?ve got the following groups:






For every tuplet (organization, meeting_date, employee) the hours worked for that employee on that day at that company will be the same for every single row in detailGroup. I want to capture the hours worked, ONCE for each unique tuplet (and therefore detailGroup) and summarize the information in the organization footer. I have the following declarations:



<variable name="my_repeated_variable" class="java.lang.Double" resetType="None" calculation="Nothing">

<variableExpression><![CDATA[new Double($F{man_days_code})]]></variableExpression> </variable>



<variable name="my_repeated_variable_SUM" class="java.lang.Double" resetType="Group" resetGroup="orl" calculation="Sum">

<variableExpression><![CDATA[$V{my_repeated_variable}]]></variableExpression> <initialValueExpression><![CDATA[new Double(0.0)]]></initialValueExpression> </variable>



The result is a sum for EVERY SINGLE row in each of the the detailGroup(s). How do I correct this?

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...