2006 IR Open Discussion Posted August 20, 2006 Share Posted August 20, 2006 By: Antonio Alonso - aaesteve Counting the occurence of a value in group 2003-12-18 01:12 I need to count how many times a certain string appears in one of the fields of my report and display that number in the group footer. Is there a way to do that other than using a subreport? For example: The state of a purchase is represented in the field $F{state} and could be "Approved", "Denied", "In progress". I would like to have in the footer something like this: Approved 12 Denied 3 In progress 22 Thanks for your kind help Antonio By: Tobias Gaekle - ike987 RE: Counting the occurence of a value in grou 2003-12-18 01:37 make variables that only count when the expression matches, like this: <variable name="countApproved" class="java.lang.Integer" calculation="Count"> <variableExpression><![CDATA[ $F{state}.equals("Approved") ? Boolean.TRUE : null ]]></variableExpression> </variable> then reference it in your footer with $V{countApproved}. By: Tobias Gaekle - ike987 RE: Counting the occurence of a value in grou 2003-12-18 01:40 i just saw you're using a group, you will probably have to set the variable attribute resetType="True" and <initialValueExpression>new Integer(0)</initialValueExpression>. By: Antonio Alonso - aaesteve RE: Counting the occurence of a value in group 2003-12-18 02:25 Thank you very much Tobias. It works great. You saved me a lot of time!!! 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