chakravarthy.9866 Posted August 3, 2016 Share Posted August 3, 2016 Hi All,My report looks like belowApr,May,Jun ,July ,Totalnull,null,120.00,null , nullI have created the variable for Sum and in Expression I have mentioned as $F{Apr}+$F{May}+$F{Jun}+$F{Jul}, in Total I am getting null value.I can understand that if we have null values in other column result will be null, how to validate the double type with null and how to calculate the total? Regards,Chakravarthy Link to comment Share on other sites More sharing options...
reportdev Posted August 3, 2016 Share Posted August 3, 2016 Simplest way would be to replace these null values as zero in your SQL with nvl function (if you are using oracle).But this can also be done using Java.First you need to create variables for each month Apr, May, Jun, July, Total. Inside these month variables check if the value is null and replace with Zero.Ex: $F{APR}!=null ? BigDecimal.valueOf($F{APR}) : BigDecimal.ZEROThen Add all these month variables inside the Total variable using .add method Ex: $V{APR}.add($V{MAY}).add($V{JUN}).add($V{JULY}) 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