SUM two different fields

I have two variable 

$V{SUM_ITEMS_SHIPPED} and $V{SUBREP_COUNT}

I want sum of these two variables using Groovy. For this, I dragged a new text field to summary band and in the "Text Field Expression" i have given as 

$V{SUM_ITEMS_SHIPPED} +$V{SUBREP_COUNT}

But the result of this concatenation of these two values and not the sum.

For ex: $V{SUM_ITEMS_SHIPPED} = 1

             $V{SUBREP_COUNT} = 0

output is "10" and not "1"

Please help me how to do this.

What "Text Field Expression" is needed to sum these two variables together ?

vspn's picture
99
Joined: Mar 14 2014 - 1:20pm
Last seen: 5 years 6 months ago

1 Answer:

Select your variable and look at it's property. By default, variables are created as String. Change the "Value Class Name" to something like "java.lang.Integer".

hozawa's picture
190283
Joined: Apr 24 2010 - 4:31pm
Last seen: 4 years 3 months ago
Feedback
randomness