dprogrammer Posted August 18, 2006 Share Posted August 18, 2006 I want to display a field value conditionally. I have created a variable and I am using this syntax in 'TextFieldExpression': $F{qtr}=="Q1" ? $F{Salary}.doubleValue():0 I am getting error "Can not cast from double to double". Link to comment Share on other sites More sharing options...
javydreamercsw Posted August 18, 2006 Share Posted August 18, 2006 Are you sure that's the exact error? I've seen myself "Can not cast from double to Double" or viceversa. For some reason Double and double, int and Integer cause those kind of errors. Anyway is either the field or the variable that have a non- matching data type. Link to comment Share on other sites More sharing options...
dprogrammer Posted August 18, 2006 Author Share Posted August 18, 2006 Here is the error:1.ÂCannotÂcastÂfromÂdoubleÂtoÂDouble valueÂ=Â(java.lang.Double)(((java.lang.String)field_qtr.getValue())=="Q1"?((java.lang.Double)field_Salary.getValue()).doubleValue():0.0); The variable and field both are of type double. Link to comment Share on other sites More sharing options...
JulEgner Posted August 18, 2006 Share Posted August 18, 2006 the FIELD is Double, so put a "new Double()" around the whole sentence and it will work.If you just dont want to DISPLAY something,use the "print when expression" in "common" of any field. Link to comment Share on other sites More sharing options...
javydreamercsw Posted August 18, 2006 Share Posted August 18, 2006 The double Double difference is what I meant in my first post. JulEgner's answer will work, at least it works for me. Link to comment Share on other sites More sharing options...
dprogrammer Posted August 24, 2006 Author Share Posted August 24, 2006 It worked when I enlcosed the whole expression with new Double(). Is this a better solution or we can play around with a field's properties and achieve same without using a variable? My goal is to display a field value if it has a value that falls in any quarter and display 0 if no value for any quarter. The layout of the report is as follows:Quarter1 Quarter2 Quarter3 Quarter4234.00 0.00 1234.56 34.00 Is is possible to do it without using a variable? 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