mistub Posted March 15, 2017 Share Posted March 15, 2017 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 More sharing options...
Solution reportdev Posted March 15, 2017 Solution Share Posted March 15, 2017 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 More sharing options...
mistub Posted March 15, 2017 Author Share Posted March 15, 2017 Thx a lot! null did the trick! Kind regards, Michael 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