Hafidzati Hikmadani
Hafidzati Hikmadani

Reputation: 21

Jasper if condition

I have a BigDecimal variable that contains number with minus(-) and not. I want to put static text that should be match with this conditions:

For example, if $V{saldo} = -250000 then the static text should be "Rugi", and if $V{saldo} = 400000 then the static text should be "Laba"

Upvotes: 0

Views: 7078

Answers (2)

Deepesh kumar Gupta
Deepesh kumar Gupta

Reputation: 896

First Check for ZERO then apply your logic

$V{saldo}.$V{saldo} != 0.0 ? ($V{saldo}.intValue() < 0 ? "Rugi" : "Laba"): "Zero"

Upvotes: 1

Tim Biegeleisen
Tim Biegeleisen

Reputation: 520878

Try using this if-else construct:

$V{saldo}.intValue() < 0 ? "Rugi" : "Laba"

Please see this SO post for more information.

Upvotes: 1

Related Questions