IF / ELSE condition in expression in Jasperreports

0

I need to perform a check in the expression field on my report created in Jasperreports studio , my situation is as follows, I need to make the following account:

$F{quantidade}/($F{quinze}/15.0)

But sometimes the count ($F{quinze}/15.0) results in zero, and it is not possible to divide by zero, so the infinity symbol ends up appearing in my report, my need is to verify that the ($F{quinze}/15.0) in 0 I want to change the return so that it is only $F{quantidade} and not the result of the account

    
asked by anonymous 16.10.2017 / 13:05

1 answer

2

Just by looking at documentation , I made this formula using ternary operation , see if it suits your problem:

(($F{quinze}/15.0 == 0) ? $F{quantidade} : ($F{quantidade}/($F{quinze}/15.0)))
    
16.10.2017 / 13:10