Jump to content
We've recently updated our Privacy Statement, available here ×

how to transform character in integer


solene.masseron

Recommended Posts

Hello everyone,
If I may, I would like to ask you because I would like to count the active or non-active numbers. This data is characterised by the number of Yes and No per municipality. 
I created a common group and a variable to compatbilise.
I set the variable as follows:
calculation: sum
expression:IF($F{arret_dorm}=="Oui",1,0)
initial value expression:$F{arret_dorm}.getValue.parseInt(Oui,1)

the problem is that the entire transformation is not happening and I don’t know how else to do it.

HELP

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Hello,

This should actually work as a problem. Your idea behind it is correct:

Depending on the value of the string (yes or no) a 1 or 0 is summed up. This gives the total sum of the records with yes.

I would simply set the Initial Expression to 1. This will be overwritten with the first record anyway.

I would set the Expression to

$F{arret_dom} != null && $F{arret_dom}.exqualsIgnoreCase("oui") ? 1 : 0

Probably your comparison with == leads to a problem. This checks the equality of objects in Java. Two strings can have the same content but be different objects.

Consider also the correct evaluation time of the text field in which you use this variable.

Greetings, Johannes

  

 

Link to comment
Share on other sites

  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...