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

How to add category/series "All together/Sum?


pawel_r

Recommended Posts

Hi

I am using grouping in order to put my data into 2 categories, but on the chart I would like to have also additional category, wich sums the values of two prevoius. Can it be done with jasperreports or I simply need to fetch additional field from database

 

Regards

Paweł

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Paweł,

 

I personally find it easier in most cases to perform the calculation in the SQL and return the extra value. But it's also possible to create a variable in the report and use this variable in the chart. The end result should be the same.

 

If you are new to variables, I recommend to start with just printing the values of the fields and the variables in a simple tabular report. Make sure you have the values that you expect. After confirming this, then put the variable into the chart.

 

Regards,
Matt

Link to comment
Share on other sites

Thanks Matt

However I think you misunderstood my question a little. Yes, generally I know how to use variables in jasperreport. The problem is that I don't see a way how my data can fall into 2 categories at ones (like "Car", "Truck", "All vehicles" - any car is an vehicle and any truck is an vehicle, so on the chart the "all vehicles" category would sum up the values of two previous). I know how to put those data on separate charts - but I would like to get it at single chart as additional category.

(Writing this post I just realized I could change my chart and use series for this aim -however I am already using series for another king of grouping)

Link to comment
Share on other sites

  • 2 weeks later...

If the report structure allows it, you can try to create a new group to sum the vehicle values, and add a new category series using the sum variable as value.  The value will be fed multilple times to the chart, but if we're lucky the last (final) value will be used in the chart.

Regards,

Lucian

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