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

Null value for DistinctCount


mistub
Go to solution Solved by reportdev,

Recommended Posts

Hi all 

I got a silly problem with DistinctCount. 

In the expression (jrxml): 

 

<variable name="TICKET_COUNT_P1" class="java.lang.Integer" calculation="DistinctCount">

     <variableExpression><![CDATA[( $F{payment}.intValue() == 1 ? $F{ticket_no} : new Integer(0))]]></variableExpression>

</variable>

 

the Null value (Integer(0) is interpreted as a distinct value and therefore - even there is no payment-type of 1 - the sum of the DistinctCounts will be 1, not 0 as expected. How do I create a real Null value that isn't counted?

 

Kind regards, Michael

 

 

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution

This will be your variable expression.

Replacing new Integer(0) with null should do the trick.

<variable name="TICKET_COUNT_P1" class="java.lang.Integer" calculation="DistinctCount">
     <variableExpression><![CDATA[( $F{payment}.intValue() == 1 ? $F{ticket_no} : null )]]></variableExpression>
</variable>
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...