Jump to content
Changes to the Jaspersoft community edition download ×

Variable=Sum(Fields)?


Recommended Posts

By: Karwan Salih - salihk

Variable=Sum(Fields)?

2002-10-24 13:01

Hi,

I've created a one-page report that has several fields with Double values retreived from the database. Is it possible to create a variable that holds the summation of those fields at the end of the page? Each page represents one record in the RecordSet.

 

Thanks.

 

 

 

 

 

By: Teodor Danciu - teodord

RE: Variable=Sum(Fields)?

2002-10-27 13:11

 

Hi,

 

Your variable should look like this:

 

<variable name="MySumVariable" class="java.lang.Double" resetType="Page" calculation="Sum">

<variableExpression>

new Double(

$F{MyField1}.doubleValue() +

$F{MyField2}.doubleValue() +

$F{MyField3}.doubleValue() +

$F{MyField4}.doubleValue()

)

</variableExpression>

</variable>

 

If you have only one record per page anyway,

the "resetType" and "calculation" attributes

could be left to their default values: "Report" and "Nothing".

 

I hope this helps.

Teodor

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...