jackiehal Posted November 15, 2020 Share Posted November 15, 2020 Hello! I want to make a Jasper Report that desplays a field and at the end it sums all the numbers from it. The problem is that the column is java.lang.String because it has dashes(-) and numbers. For example I have the column in the picture. I create a variable that sums every number of the column. For every dash it should add a zero. So for the example column the result should be sum=282. I tried the following.IF(Boolean.valueOf($F{Column}).equals("-") ? $V{Sum} = $V{Sum } + 0 : $V{Sum}= $V{Sum} + Long.parseLong($F{Column}))But it gives an error "The left-hand side of an assignement must be a variable"Does anyone have any ideas on how to do it correctly? Thank you! Link to comment Share on other sites More sharing options...
gustavofarias Posted November 15, 2020 Share Posted November 15, 2020 Create an Integer variable named "Sum", set it's calculation to "Sum" and set it's expression to $F{Column}.equals("-") ? 0 : Integer.parseInt($F{Column})[/code]Basically this is what you are already doing. But, you can instruct Jasper to make the sum for you, so your expression doesn't have to make assignments, it just returns the value of the current record. Link to comment Share on other sites More sharing options...
gassenga080 Posted November 16 Share Posted November 16 (edited) Is this applicable if you are returning a view? Edited November 16 by gassenga080 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