Jump to content
Changes to the Jaspersoft community edition download ×

Newbie: Count text column/field?


Recommended Posts

Hello... Newbie here. I have a column that contains the text of either High, Medium, and Low. I would like to count say all High's. How do I do this? I have tried creating different variables but unable to get it to work. Any chance someone can give me the variable configuration? Thanks...
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

create a new variable called (say) $V{HighCount) as java.lang.Integer with a Calculation Type of Sum and an Initial Value Expression of new java.lang.Integer(0)



The Variable Expression would then be new java.lang.Integer($F{yourFieldName}.equals("High") ? 1 : 0)




Post edited by: jmurray, at: 2007/06/27 01:54

Link to comment
Share on other sites

JM, thanks for your help. The variable you gave me works but when I use "High" I get a value of 26. There is actually 13 high's so it seems to be counting the 2 H's. I have tried different variables but I still get doubles. If I create a variable for "Low" it works fine. If I create a variable for "Medium" I get doubles also. What do you think I am missing/doing? Thanks...
Link to comment
Share on other sites

  • 5 years later...

I have a similiar issue.. I have busses, that have three status's In Service, Operational but needs work and out of service. They are grouped by location.

I got it to count the in service status but it will only do it per line. I would like to do it per LOCATION.. now how do I add that in.. right now I have the Variable.. InServCount And the properties for that show: Value Class Name: java.lang.String, Calculation: Sum, Expression new java.lang.Integer($F{Status}.equals("In Service") ?1:0)

Initial Value Expression: BLANK

Increment type: Group1 (this group is my Location--only one group)

Incrementer Factory Class Name is BLANK

Reset Type GROUP1

Any help would be greatly apprecieated.. The Group1 field name is YARD



Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...