dougb_1 Posted March 8, 2013 Share Posted March 8, 2013 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 More sharing options...
rlfisherpbtgroup.com Posted March 9, 2013 Share Posted March 9, 2013 You could change it in the query. In MySQL it would be something like CAST(plaste AS UNSIGNED). I'm no Java expert, but in the jrxml expression you could do something like $F{plate}.longValue() + 1 -- though it should have a conditional to return something (null or 0) if plate is not a number. Link to comment Share on other sites More sharing options...
C-Box Posted March 9, 2013 Share Posted March 9, 2013 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) hthC-Box Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now