Jump to content
We've recently updated our Privacy Statement, available here ×

How can I count or sum a string?


mdgimm

Recommended Posts

The purpose of my variable to is to count the number of individuals who have a legal status of "PROBATION".  My expression is set as such:

<variable name="ProbationCount" class="java.lang.Integer" resetType="Group" resetGroup="AgntName" calculation="Sum">
        <variableExpression><![CDATA["PROBATION".equals($F{o_lgl_status}) ? 1 : 0]]></variableExpression>
    </variable>

this however returns a count of zero, which I know is false.  

How can I count or sum a string such as "PROBATION" using Jaspersoft Studio v. 5.6.0?  Your clarity in this area is greately appreciated.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Hi, 

Possibly the error in counting could be because of  any of the following reasons:

1. You would have set the Increment Type property wrongly, according to the grouping you have in the report this would vary but, if you have a single group then the default value will do that is None, which will allow to run the count expression to run for every record.

2. Other possible error could be that you would have missed on a default value property, this should be set to 0 as you will be further adding on the values.

3. Other important aspect could be the reset group you have set, , if you have more than 1 groups then you should place the variable in a place which shows the value before it is reset, that is before the second value of the group is encountered.

4. Last but not the least could be that you have placed the variable in the group header or a place where either the calculation is yet not completed or a place where the execution comes after the reset which leaves your variable value unchanged.

 

I would suggest you that if you have more than one groups then gradually check the positioning of the variable.
Along with this I am attaching a snapshot of the property window of the variable,

Capture(16).PNG.c223468ef629f4b8b5ba86dda354921f.PNG

 

Hope that this helps
Thanks
Ankur Gupta
ankurthetechie.blogspot.com

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...