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.Integer
Calculation = Sum
ResetType = Column
Increment type = Column
Initial Value Expression = 0
Variable expression = $F{Code} != null ? 1 : 0
My result:
Code Total
A 1
B 1
C 1
A 1
C 1
What I need:
Code Total
A 2
B 1
C 2
How can I do it in Jasper without using sql?
Thank you so much.
5 Answers:
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.
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.Integer
Calculation = Count
ResetType = [Groupname] Group
Increment type = None
but the column CountCode value is null. Why?
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.