Jump to content
We've recently updated our Privacy Statement, available here ×

Why JasperReports doesn't calculate correct total?


partizan1

Recommended Posts

Hi,

Has anyone else encountered the problem of not being able to use the Sum function on a Variable? I need to calculate the total number of a column value (i.e. AFFECTED_ROWS column in my table). I have the variable 'totalNumbAffected' which has the Properties set to:

Variable Class: Double

Calculation: Sum

Reset type: Report

Increment type: None

Variable Expression: $F{AFFECTED_ROWS}

 

If I print the variable on my report, it does display the correct sum. However, if I try using it in my Pie Chart, for each pie slice the value is different and therefore it's incorrect (except for the last pie slice). My question is - How can I calculate the Sum of my column before it's used in my pie chart so that the value is the same for all pie slices?

 

Can someone help please?

Thanks,

partizan

 

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I found out how to get the percentage. This forum helped me: http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=49687

Please refer to this quote by Teodor:

"In JasperReports version 3.1.0, we have introduced two new properties to control the appearenace of section labels and legend labels. These two are called labelFormat and legendLabelFormat.

You can use {0}, {1} and {2} for displaying the key, the value and the percentage in pie charts.

For these formats to be used, you have to leave the labelExpression empty.

I hope this helps." by Teodor

 

I hope that helps to the rest of you having this problem.

 

Cheers,

partizan

Link to comment
Share on other sites

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