if-else-if-else in textfield expression

teon picture teon · Jan 13, 2011 · Viewed 79.1k times · Source

I have to show columns: - send - receive - cancelled

In a report column by checking a value from DB which is "Status". So if Status equals 1 then send,=2 receive , = 3 cancelled.

The textfield expression in jasper report ( ? a:b) can only take one condition, how do i give multiple conditions ? something like if-else ladder ?

Answer

Gordon picture Gordon · Jan 13, 2011

You can use a nested ternary statement to achieve this but it's messy.

For example:

(i == 1) ? "Send" : ((i == 2)? "Received" : "Cancelled");