# Is it possible to calculate total within the ireport parameter?

Tina Ma

Ranch Hand

Posts: 198

posted 5 years ago

I am building up the object which will be printed out using ireport. At present I am calculating the totals in my java code. Is it possible to pass over the calculation burden to ireport? Is it possible to put a parameter in the ireport which will command it to calculate the total and display that value based on the values in the column displayed so far?

Tina

SCJP 1.4, SCWCD 1.4

bilal sidiqui

Author

Greenhorn

Greenhorn

Posts: 17

posted 5 years ago

Hello Tina,

I'm not sure exactly what you are doing, but it appears you need to do some calculations in your report. All calculations are generally part of the *report design procedure* and should not have anything to do with java code. JasperReports provides rich features to do everything from simple sum and average to complex mathematical calculations over whatever records you chose. And you can use all these features of JasperReports with iReport.

My JasperReports book demonstrates the whole *design procedure* of reports that require logical, mathematical, or statistical calculations. You may want to go through the sample chapter (titled "Using Mathematical and Logical Expressions") of the book that is available for free download:

http://www.packtpub.com/sites/default/files/downloads/0769os-chapter-9.zip

The chapter demonstrates and explains how to calculate the sum/average/maximum of a column or things like that.

I'm not sure exactly what you are doing, but it appears you need to do some calculations in your report. All calculations are generally part of the *report design procedure* and should not have anything to do with java code. JasperReports provides rich features to do everything from simple sum and average to complex mathematical calculations over whatever records you chose. And you can use all these features of JasperReports with iReport.

My JasperReports book demonstrates the whole *design procedure* of reports that require logical, mathematical, or statistical calculations. You may want to go through the sample chapter (titled "Using Mathematical and Logical Expressions") of the book that is available for free download:

http://www.packtpub.com/sites/default/files/downloads/0769os-chapter-9.zip

The chapter demonstrates and explains how to calculate the sum/average/maximum of a column or things like that.

Bilal Siddiqui, Author of JasperReports 3.6.0 Development Cookbook