Can be to sum text values in a jasper report ?

Hello everyone

I’m a little desperate. I try to sum up the number of yes and no that there is in my transport stop table that is in database and I do not understand what is wrong with it.

I created a variable configured this way:
name value class: java.lang.integer
calculation: sum
expression:IF($F{arret_dorm} ="Non",1,0)
intimate value expression: 0
increment type: none
type réinitialisatio common group

and then I put this variable in the header detail, knowing that I have a band.
The problem is that it always appears 0 as a value. If I set 1 to the initial value, it remains 0.

I’m not sure what to do any help will be welcome

solene.masseron's picture
Joined: Mar 9 2021 - 7:38am
Last seen: 1 month 1 week ago

2 Answers:

Hello,

You can try using compareTo() function this function accepts string and if it matches to provided string then it will return 0.

so you can try using expression something like below and set true value as 1.

IF($F{arret_dorm}.compareTo( "Yes")==0,1,0)


Hopefully this will help you.
 

jphadtar's picture
1109
Joined: Mar 20 2022 - 10:51pm
Last seen: 9 hours 39 sec ago

Hello , 

Thank you for your answer, but he does not calculate the sum of the values. He does a count. Knowing that in the variable in the calculation tab there is sum.

Thank you for your help

solene.masseron's picture
Joined: Mar 9 2021 - 7:38am
Last seen: 1 month 1 week ago
Feedback