striperfishingmail.com Posted July 23, 2012 Share Posted July 23, 2012 I have a report I am developing in iReport 3.7.1 which uses XML as a datasource. The XML is structured as follows:<Students> <Student> <Name>Mark</Name> <Major>Computer Science</Major> <Grade>Undergrad</Grade> </Student> <Student> <Name>John</Name> <Major>Computer Science</Major> <Grade>Graduate</Grade> </Student> <Student> <Name>Bill</Name> <Major>English</Major> <Grade>Undergrad</Grade> </Student></Students>In my Jasper report, I have a QueryString for "/Students/Student" and I am grouping the records on the element "Major". This works fine, however, I only want to print one particular value(static label) in my Group Header if at least one record exists in the Group with Grade="Graduate". Is anyone aware of a way I can accomplish this? I was wondering if there was any way to use a Variable with a reset type of Group to do it, but can't seem to find a solution that works. Link to comment Share on other sites More sharing options...
striperfishingmail.com Posted July 24, 2012 Author Share Posted July 24, 2012 I have one update to my original post. I am able to add a Field (GraduateStudentCount) to the report with a description of "count(Grade[text()=Graduate])" which renders a count of the number of records with Grade=Graduate. This will be either 1 or 0 depending upon whether the Grade is set to Graduate. I can then a variable with the following attributes:Variable Class: java.lang.IntegerCalculation: SUMReset Type: GroupReset Group: <my group name>Variable Expression: $F{GraduateStudentCount}Initial Value Expression: new Integer(0) If I add this variable to the header band of my group and then set the Eval Time to GROUP, it correctly renders the number of Students in the Group with Grade=Graduate. However, I need to use this value in an expression. If I try to use the Variable directly, it is always 0. Is there a way to set the Variable's eval time to Group? 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