pelmenipeter Posted March 25, 2009 Share Posted March 25, 2009 Hallo, i´m searching for 2 days of a solution.I have a integer field called $F{REJECT} Then a variable called $V{REJECT_1} This variable should count how often the number 3 exist in $F{REJECT}I could count all numbers but i dont know how to count only the number "3".Please help.Thanks in advance. Link to comment Share on other sites More sharing options...
kchaudhry Posted March 25, 2009 Share Posted March 25, 2009 Try this in the variable expression.Code:($F{REJECT}.intValue() = 3) Link to comment Share on other sites More sharing options...
pelmenipeter Posted March 26, 2009 Author Share Posted March 26, 2009 if i use this in variable expression IReport said:The left-hand side of an assignment must be variable Link to comment Share on other sites More sharing options...
mdahlman Posted March 27, 2009 Share Posted March 27, 2009 pelmenipeter, You'll need to do a variable that does a sum (rather than a count) more like this: new Integer( ($F{REJECT}.intValue() == 3) ? 1 : 0 )I didn't test the syntax, but this idea should be what you need.Regards,Matt Link to comment Share on other sites More sharing options...
iddsathish Posted March 29, 2009 Share Posted March 29, 2009 Hello,U can try this out alsoFirst u set $V{REJECT_1} as new Integer(0) in initial expressionThen put this expression in variable expression $V{REJECT_1} .intValue() + ( $F{REJECT}.intValue() == 3? 1:0) Try this out it will work. Link to comment Share on other sites More sharing options...
pelmenipeter Posted March 29, 2009 Author Share Posted March 29, 2009 hello,thanks for your answers but i have found the correct expression, but i´m not @ work, so i´ll post the code on monday.But i have the problem, that i couldn´t set a field from an xml file to integer. I have this problem in version 3.1.4 and in 3.5. If i set the field to integer in version 2.0.5 the report works.In the two older versions i´ve tested, i get an NullPointerException. I dont know why. I have to set the field to string an it works, but the string isn´t usefull.Code:Here is the code for count the number 0 in the field USAGE($V{USAGE}.intValue()==0?"":null)Post Edited by Peter König at 03/30/09 05:17 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