K.S. Posted March 13, 2016 Share Posted March 13, 2016 Hi,In JaspersoftStudio make a Jasperreport with 2 columns: Code (unique value field "code" for a certain period of time) and Total (how many times the value of the field "code" is repeated). I have a variable $V{CodeCount} with properties:Variable class = java.lang.IntegerCalculation = SumResetType = ColumnIncrement type = ColumnInitial Value Expression = 0Variable expression = $F{Code} != null ? 1 : 0 My result:Code TotalA 1B 1C 1A 1C 1 What I need:Code TotalA 2B 1C 2How can I do it in Jasper without using sql? Thank you so much. Link to comment Share on other sites More sharing options...
hozawa Posted March 13, 2016 Share Posted March 13, 2016 Why are you "summing" (Sum) instead of "counting" (Count)? I'm not sure why you havae an expression when you've set Count. Not sure why you've set Increment Type either. Also, do you have the list sorted by Code? It would be better if you've Grouped by Code, then you can just have Reset on Group Code. Link to comment Share on other sites More sharing options...
K.S. Posted March 14, 2016 Author Share Posted March 14, 2016 I found a solution to create Group Header and place there $FCode (i have result not A B C A C, and A B C), but I can not count how many times the value is repeated. I try to create Variable $V{Count_Code} with properties:Variable class = java.lang.IntegerCalculation = CountResetType = [Groupname] GroupIncrement type = Nonebut the column CountCode value is null. Why? Link to comment Share on other sites More sharing options...
hozawa Posted March 14, 2016 Share Posted March 14, 2016 Did you set the initial value? Link to comment Share on other sites More sharing options...
zh3ntil Posted March 15, 2016 Share Posted March 15, 2016 Hi,I assume that you use the variable on Group header, not on group footer. So you have to set the evaluation type of the textfield which is used for variable on table. Select the text field and go the properties. Under the 'Text Field' section, set the evaluation type as '[Groupname] Group' and try again. You should see the proper values. Link to comment Share on other sites More sharing options...
K.S. Posted March 17, 2016 Author Share Posted March 17, 2016 I found a solution. I added a variable to a group and in TextField pointed out Group Changes [GroupName] and it worked. 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