Jump to content
Changes to the Jaspersoft community edition download ×

Using OR in the Print When Expression field


amyerson

Recommended Posts

I need to print when either of two expressions is true. I've tested each expression independently, and they work. But when I put them together using ||, only the floatvalue one works. Basically, I need it to print any line that's not the ACA Fee or if the bill amount is not 0. The expression I'm trying to use is:

(!$F{pay_type}.equals("ACA Fee"))||($V{bill_amt}.floatValue() != 0.00)

I've tried adding (), and even made it the if/then statement below.

((!$F{pay_type}.equals("ACA Fee"))||($V{bill_amt}.floatValue() != 0.00)) ? Boolean.TRUE : Boolean.FALSE

If I just use !$F{pay_type}.equals("ACA Fee"), that works just fine. 

Any help would be greatly appreciated since I've never been trained on Jasper and I'm learning as I go.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Tried and it worked for me. The only change is that is Java, floating point shouldn't be compared using "==" because of precision.

Try the following:

!$F{pay_type}.equals("ACA Fee")) || $V{bill_amt}.floatValue() > 0.01

or

!$F{pay_type}.equals("ACA Fee")) || $V{bill_amt}.intValue() != 0

Link to comment
Share on other sites

  • 2 years later...

@hozawa, that doesn't seem to work. I have the same issue, where one field has a psecific text or another field is zero, then don't print. The following experssion prints all the time:

!$F{expense_category}.equals("Home Rent") || $F{expense_amount}.compareTo(BigDecimal.ZERO) != 0

Suggestions?

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...