dprogrammer Posted November 20, 2008 Share Posted November 20, 2008 Hi, I have two fields which are numeric. I have created two variables for them and converted them as double. Now I have created a third variable to do their subtraction. See example below: Say Avg1= 100 and Avg2 = null, the result should be 100, but I am getting null.new Double ($V{Avg1} - $V{Avg2})The result in third variable is coming up as null whereas it should be 100. I want to check for nulls and then convert them into 0 but now sure about the formula code. Any ideas please? Link to comment Share on other sites More sharing options...
hangman01 Posted November 20, 2008 Share Posted November 20, 2008 If the values are selected from database by a query you can use nvl(avg2,0) avg2 to change null values to zero. Otherwise I would do something like avg2.equals(null)?avg2 = 0 Link to comment Share on other sites More sharing options...
sdemills Posted November 21, 2008 Share Posted November 21, 2008 Am I correct in thinking the last part should have read avg2.equals(null) ? 0 : avg2 Link to comment Share on other sites More sharing options...
bmagoha Posted November 26, 2008 Share Posted November 26, 2008 You can also use coalesce() sql function, that is if u are retrieving them from db. Link to comment Share on other sites More sharing options...
hangman01 Posted November 26, 2008 Share Posted November 26, 2008 Yes that should work. 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