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

Should be easy - string to integer (to get sum)


dougb_1

Recommended Posts

This seems like it should be easy, but I can't get it working.

Using iReport 5.0, there is a field called Plates.  In the database, it's a custom/user defined field, so iReport recognizes it as a string.  But the values are usually numbers (as strings.)

If displayed, it might be blank, or "5" or "3" or something. 

How can I convert it to a number?  I want to get a SUM of those strings, but I can't even get it to display with a simple calculation, such as $F{plate} + 1.  I tried various combinations of Field expression, Variable expression, and more. Ideas would be greatly appreciated.

Thanks,

Doug

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Try this as variable expression:

$F{plate} == null?0:Integer.valueOf($F{plate})[/code]

This should parse your string field to an Integer object... but be aware if it contains characters it will throw an error (as Strings can't ne summed up)

 

hth

C-Box

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