How to find sum of column in Ireport or jasper report?
Solution 1
A variable is defined and
variable expression
to
$F{thScore}+$F{prScore}
and
calculation
to
sum
.It worked for me where $F{thScore},$F{prScore} are fields in detail band.
Solution 2
I had a fields of Integer type and was trying to add the columns . I was not getting any error when the report is previewed but my java application was failing to compile the report and giving the error as
The operator + is undefined for the argument type(s) java.lang.Integer, java.lang.Integer value = (java.lang.Integer)(((java.lang.Integer)field_nBSRptSchm1Col1.getValue())+((java.lang.Integer)field_nBSRptSchm2Col1.getValue())); //$JR_EXPR_ID=8$
then I used the following code to add the columns of Integer type...
new Integer($F{nSchm1Col1}.intValue() + $F{Schm2Col1}.intValue() )
where nSchm1Col1
and Schm2col1
are two fields which I want to add. This one worked for me
Related videos on Youtube
![kinkajou](https://i.stack.imgur.com/BesVN.png?s=256&g=1)
kinkajou
I am a programmer. I like learning new things. The profile picture is not me it's : The kinkajou (Potos flavus) is a rainforest mammal of the family Procyonidae related to olingos, coatis, raccoons, and the ringtail and cacomistle. It is the only member of the genus Potos and is also known as the "honey bear" (a name that it shares with the sun bear).
Updated on June 02, 2022Comments
-
kinkajou about 2 years
I have column in detail band with value
$F{thScore}+$F{prScore}
I would like to find the sum of this column in run time . How is this possible in jasper report using Ireport. I did it with variable but with no luck.
-
sam yi almost 12 yearsIs using variables the only way to sum up columns? Even in tables? If I have 30 columns, do I have to manually set up 30 separate variables??