Jump to content
We've recently updated our Privacy Statement, available here ×

Groovy expressions


rajeevt

Recommended Posts

I am trying to show a calculated field as a percentage. I have given the field type of BigDecimal and created an expression to display as one decimal percent.

 

My expression is:

 

($F{available}- $F{booked})/($F{available} - $F{sup_booked})

 

It works correctly when $F(available) and $F{booked} are

not same. When they are it gives 0 and it seems that the report requires 0.0 so I created the following expression:

 

($F{available}- $F{booked}) == 0? 0.0 : ($F{available}- $F{booked})/($F{available} - $F{sup_booked})

 

This one works fine but fails when both $F(available) and $F{booked} are zero.

 

Surely there must be a straightforward way of doing this calculation. Can somebody point out what I am doing wrong?

 

Regards

Rajeev

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...