${Budget}.subtract($F{Actual})
will return a BigDecimal
reference, so you cannot use division symbol /
because this is only supported for primitives (and their class wrappers when unboxed). So, you should use BigDecimal#divide
instead.
${Budget}.subtract($F{Actual}).divide($F{Budget})
From your question edit:
Caused by: java.lang.ArithmeticException: Division by zero
Your $F{Budget}
variable should not have a zero value. You could use a ternary operator to solve this problem:
${Budget}.subtract($F{Actual}).divide( ($F{Budget}.compareTo(BigDecimal.ZERO) == 0 ? BigDecimal.ONE : $F{Budget}) )
From a new comment:
I need if $F{Budget} is zero that calculation field gets assigned zero and a number other wise.
Just modify the usage of ternary operator:
($F{Budget} == null || $F{Budget}.compareTo(BigDecimal.ZERO) == 0)) ? BigDecimal.ZERO : $F{Budget}.subtract($F{Actual}).divide($F{Budget})