Sadakar Pochampalli

1) Calculating Percentage from java.lang.BigDecimal Types

By default all the numeric fields in report takes java.math.BigDecimal & you can not perform arithmetic operations like division for calculating percentages. (Alternatively you need to work with the methods from BigDecimal class to get % kind of things)

NOTE : $F{Field1} and $F{Filed2} are of java.math.BigDecimal types .4) Increment type : None5) Reset group : If you are creating variables in any data set & using it in table component give your GROUP Name

6) Drag the variable on to the design area of table component.7) Double click the variable to open it's expression a) By default you can see it's expression as $V{Variable_1} b) Change the variable expression to new DecimalFormat("#.##").format(Double.valueOf($V{Variable_1}))+"%"

2) Two decimal places after floating point for java.math.BigDecimal type values

$V{Variable_2}.setScale(2, java.math.RoundingMode.HALF_UP)+"%"This is on dragged variable. Not in the variable directly. The variable initially $V{Variable_2}. Double click it to get it's expression editor

March 5, 2015

About

Planet Jaspersoft aggregates blog posts from our community. If you would like your blog to be included in the Planet, please follow this help guide. Or just click this link to go straight to your Planet Feeds.