sukeshpvs Posted June 21, 2012 Share Posted June 21, 2012 i have a field created in sql which is a count having 1,2,3,4 values iterativelylike 1,1,1,2,4,1,2,3,1,3,4,5,3,2,3,2,4,2,3,etc... now i need a report variable to get the count of no of 1's and no of 2's 3's and 4 'si am declaring variable expression as --> $F{count}.equals(1) and calculation as countbut i am unable to get the value any one help me out... Link to comment Share on other sites More sharing options...
cmatthews Posted July 8, 2012 Share Posted July 8, 2012 It's a report context sensative question ... And there are several ways to solve for this one, but I'll take a stab at it, based on your sample it looks like you know your going to have a certain maximum number of those values to count, in your sample it was up to 4, so assuming it's 4 you could use four variables to count the numbers and set the variables on a row level to either 0 or 1. $V{countOfOnes}$V{countOfTwos}$V{countOfThrees}$V{countOfFours} Now you have a variable expression where you set the resulting value of the variable to either 0 or 1 based on the rows value. Put this code in the $V{countOfOnes} variable and place it on the row (set the print when expression = Boolean.FALSE so it doesn't ever show this on the report)($F{count}.intValue() == 1) ? 1 : 0Then create a sum variable in the appropriate summary band as needed for each of the countOf##### variables. Should result in a sum represending the count of each type, once you have that you can format it in output however you like.Just for a little more clarification, each one of the variables "countOfOnes, countOfTwos" etc should have the appropriate equal check,$V{countOfOnes} with expression = ($F{count}.intValue() == 1) ? 1 : 0$V{countOfTwos} with expression = ($F{count}.intValue() == 2) ? 1 : 0$V{countOfThrees} with expression = ($F{count}.intValue() == 3) ? 1 : 0$V{countOfFours} with expression = ($F{count}.intValue() == 4) ? 1 : 0etc, etc.Good luck,Clark Post Edited by cmatthews at 07/08/2012 22:29 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