amartin_2 Posted March 5, 2015 Share Posted March 5, 2015 Based upon other questions that seem similar, I have tried the following formula. I am getting null. This should be as simple as 3.00/2 and display 1.50 however it is not working it still shows null. I have confirmed that the fields contain values for all fields. The Price Qty field is an integer and the Price field is BigDecimal, but this sets the values to double for the purposes of this variable correct? Anyone know what I am missing?new Double($V{UnitPrice}.doubleValue() == 0 ? 0 : ($F{Price Qty}.doubleValue()/$F{Price}.doubleValue())) Link to comment Share on other sites More sharing options...
Solution nuno-miguel-lourenco Posted March 5, 2015 Solution Share Posted March 5, 2015 As you are referencing a Variable, I would say that $V{UnitPrice} is NULL, and therefore your final result is also NULL Link to comment Share on other sites More sharing options...
amartin_2 Posted March 5, 2015 Author Share Posted March 5, 2015 I removed the "new Double($V{UnitPrice}.doubleValue() == 0 ? 0 : " portion from the above code and it calculates correctly now!!! Thanks for the help! It is giving me.5 I would like to see two decimal places, do you know how to do that? Link to comment Share on other sites More sharing options...
nuno-miguel-lourenco Posted March 6, 2015 Share Posted March 6, 2015 Sure. You just need to something like the following: new java.text.DecimalFormat("#0.00").format() 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