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

affan.shemle
Go to solution Solved by Ankur Gupta,

Recommended Posts

I am using iReport to create a report that is based on Oracle SQL query.  There is a % column in my report values of which are in percent like 10 %, .98 %, etc. I want the column to look like "Wish" as shown below:

 

Existing                          Wish

10 %                                10 %

.98 %                               0.98 %

15.32 %                          15.32 %

100 %                             100 %

11.9 %                            11.90 %

 

How can I do this?

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

Hi , 

This could be done by including the expression like for the text field which contains the percentage :

I have assumed that the percentage coming from the datasource is of double type.

For the case When the Percentage coming from the Data source is already calculated percentages.

($F{percentage} - $F{percentage}.intValue() !=0 )
?  new java.text.DecimalFormat("###.00 ").format($F{percentage})   + " %"
:  
new java.text.DecimalFormat("###0 ").format($F{percentage})   + " %"

For the case When the Percentage coming from the Data source is not calculated percentages and needs to be multiplied with 100 or calculated. 

($F{percentage} - $F{percentage}.intValue() !=0 )
?  new java.text.DecimalFormat("###.00 %").format($F{percentage})   
:  
new java.text.DecimalFormat("###0 %").format($F{percentage})   

 

Hope that this helps

Thanks
Ankur Gupta 
http://ankurthetechie.blogspot.in/
 

Link to comment
Share on other sites

Thanks Ankur. Right now I have modified my Oracle SQL query to convert the numbers in specific format model using to_char(n, '990.99') and it is giving me desired result. Can you tell me if I have to format the numbers in iReport instead of query in future where I am suppose to put the code given by you? Is it in the text field expression properties in the properties window?
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...