PP Ocean Posted June 30, 2020 Share Posted June 30, 2020 Hi,I have 3 fields with below condtions. Can someone help me with text field expression?IF "Column 1" equals "A" THEN "Text 1"ORIF "Column 2" equals "B" THEN "Text 2"ELSE"Column 3" Link to comment Share on other sites More sharing options...
Solution jgust Posted June 30, 2020 Solution Share Posted June 30, 2020 In Jasper the supported java IF statement is called a Java Ternary Operator.Here is the format: (expression) ? value if true: value if falseExample:$F{Column1}.equals( "A" ) ? "Text 1" : $F{Column2}.equals( "B" ) ? "Text 2" : $F{Column3}[/code]In case your ternary gets more complicated here is a link to an article on Java basic operators. This will be helpful if you need to add an AND (&&) or and OR (||) condition.https://www.tutorialspoint.com/java/java_basic_operators.htm Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now