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} / 3

## 2 Answers:

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);`

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);`

hth + regards

C-Box

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

Thank you C-Box and Pawan for both of your helps, I appreciate it.

That worked for me :)

Matthew