Print When Expression with multiple conditions...


iReport version 4.0.2, I have a field that should only print when multiple other fields have certain values.

$F{ONE}.equals("Yes") && $F{TWO}.equals("No") || $F{THREE}.equals("No")
So ONE has to be Yes and TWO or THREE have to be no, and this field will print. I've tried multiple ways attempt to get it to work using : ? if-else and making Booleans, but nothing  I've tried works. Help would be appreciated!
lucasleanna's picture
Joined: Mar 12 2014 - 9:03am
Last seen: 2 years 4 months ago

1 Answer:


Ternary statments. The format will mimic the following syntax, however within your report you would want to omit the semicolon at the end of the statement.

     [Condition] ? [value if true] : [value if false] ;

You might be able to do what you want with one ternarystatement like ...

     $F{ONE}.equals("Yes") && ($F{TWO}.equals("No") || $F{THREE}.equals("No")) ? TRUE : FALSE

You might need to nest multiple ternarystatements like ...

     $F{ONE}.equals("Yes") ? $F{TWO}.equals("No") ? $F{TWO}.equals("No") ? TRUE : FALSE

I don't think my syntax is 100% right, especially on the nested example, but this should point you in the right direction.


jeffrey.hegeman's picture
Joined: May 20 2013 - 8:11am
Last seen: 5 years 1 month ago

Thank you :) The first one with just one statement, I tried and it didn't work. Second one, yes the syntax looks iffy...but it's somewhere new to start!

lucasleanna - 6 years 12 months ago