ILdar Valeev Posted June 13, 2013 Share Posted June 13, 2013 I have two integer data colums and their summ calculated for groups like that:<variable name="dept_COLUMN_A_SUM" class="java.lang.Integer" resetType="Group" resetGroup="DEPT_GROUP" calculation="Sum"> <variableExpression> <![CDATA[$F{COLUMN_A}]]> </variableExpression></variable>I want to add third column with percentage of ColumnA in Column B: ColumnC = ColumnA / Column B * 100% How can i calculate percentage for the group footer? dept_COLUMN_A_SUM / dept_COLUMN_B_SUM * 100 Link to comment Share on other sites More sharing options...
Solution Ankur Gupta Posted June 14, 2013 Solution Share Posted June 14, 2013 Hi ildar,You can simply put a field with the expression dept_COLUMN_A_SUM / dept_COLUMN_B_SUM * 100 in the group footer , and you would get the result.And yes do crosscheck the type of the textfield which contains the expression , it should be same as the type used for the variables. I hope for the variables dept_COLUMN_A_SUM and dept_COLUMN_B_SUM you have set the reset types as the group concerned Hope that it helpsThanks,Ankur Gupta Link to comment Share on other sites More sharing options...
ILdar Valeev Posted June 14, 2013 Author Share Posted June 14, 2013 I forgot to set the "reset type" for the variable. And another thing: I added a condition to variable expression to avoid zero division. $V{dept_COLUMN_B_SUM}>0 ? ($V{dept_COLUMN_A_SUM} / $V{dept_COLUMN_B_SUM})*100 : 0.0 Link to comment Share on other sites More sharing options...
Ankur Gupta Posted June 14, 2013 Share Posted June 14, 2013 Yeah that would be great !! 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