matthew.friendars.usda.go Posted November 15, 2019 Share Posted November 15, 2019 Hi Folks:I tried reading the latest Studio user guide chapter on Variables but I'm looking for some practical examples. Videos or practical examples on how to work with them would be great.For example: I have a totals field that is the sum of x3 fields. I want to be able to take the variable: $V{CORN1_MEASURE} and divide it by three. I've tried reading the chapter on variables but still can't get it. What I want is something like: $V{CORN1_MEASURE} / 3http://cwebpro.com/crosstab_jaspersoft.png Link to comment Share on other sites More sharing options...
Solution C-Box Posted November 15, 2019 Solution Share Posted November 15, 2019 if you use some BigDecimal types for your measures you must be aware of the RoundingMode and the expected scale. ... eg following divides by 3 and rounds half up and set the scale to 2 digits after the decimal separator:$V{CORN1_MEASURE}.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP);[/code]Be aware that your measure isn't null.... otherwise make a simple If-Then-Else Check before:$V{CORN1_MEASURE} == null ? BigDecimal.ZERO : $V{CORN1_MEASURE}.divide(new BigDecimal(3), 2, BigDecimal.ROUND_HALF_UP);[/code]hth + regardsC-Box Link to comment Share on other sites More sharing options...
pawankumar.singh Posted November 18, 2019 Share Posted November 18, 2019 when you are creating variable then you can do First you just create variable and provide value class name like if you want to divide it by 3 then your field must be class of double/integer/long. After that you are able to divide by 3.eg. $V{CORN1_MEASURE}.doubleValue()/3 try this.Hope this will help.Pawan Link to comment Share on other sites More sharing options...
matthew.friendars.usda.go Posted November 18, 2019 Author Share Posted November 18, 2019 Thank you C-Box and Pawan for both of your helps, I appreciate it.That worked for me :)Matthew 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