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

Variable Expressen String to Double


shining01

Recommended Posts

Hello,

i use Jasperreports 5.2 and iReport 5.5.0. I have to String Fields with numeric values. i would like to calculate this two fields in one variable.

My Variable expression is:

new Double($F{SUMMEBESTELLMENGE}.toDouble()-$F{BESTAND}.toDouble())

Fehler: Error evaluating expression :
    Source text : new Double($F{SUMMEBESTELLMENGE}.toDouble()-$F{BESTAND}.toDouble())

The Report Language is groovy.

i have tried also Double.valueOf(Double.valueOf($F{SUMMEBESTELLMENGE}).doubleValue()*Double.valueOf($F{BESTAND}).doubleValue()). but also with error.

 

I call the report in my Java Programm.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hello everybody,

 

i have found my mistake. There was a null value. Now it works with this syntax:

$V{SumErwarteterZugang}-(($F{BESTAND} == null || $F{BESTAND}.length()<=0)?new Double(0.0):Double.parseDouble($F{BESTAND}))-(($F{SUMMEBESTELLMENGE} == null || $F{SUMMEBESTELLMENGE}.length()<=0)?new Double(0.0):Double.parseDouble($F{SUMMEBESTELLMENGE}))

 

Thanks

Link to comment
Share on other sites

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...