rghanta Posted September 29, 2008 Share Posted September 29, 2008 I have two Variables whose Variable Class Types are "java.math.BigDecimal". My requirement is to calculate the percentage of those two Variables and display it in the format "XY %". Something like ((Variable1/Variable2)*100) in plain mathematics. I see some methods like divide(), multiply() etc in the Expression Editor. But I am not sure of how to use those expressions. Can some body help me to achieve this in iReport.Thanks in advance.Best Regards,Ram... Link to comment Share on other sites More sharing options...
kchaudhry Posted September 29, 2008 Share Posted September 29, 2008 There are a couple of ways of doing this. 1. Create a new text field 2. Right click on the text field and go to Properties then Text Field tab3. Change the Text Field Expression Class to java.lang.Double4. Now enter the following in the Text Field Expression boxnew Double($V{yourvariable2}.doubleValue() == 0 ? 0 :($V{yourvariable1}.doubleValue()/$V{yourvariable2}.doubleValue()))In order to change the pattern, simply go to pattern > create > percentage and select your desired pattern.Hope this helps! Link to comment Share on other sites More sharing options...
rghanta Posted September 30, 2008 Author Share Posted September 30, 2008 Hi Kaleem, Thank you very much. That worked for me. Regards, Ram... 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