robertdseals Posted August 31, 2011 Share Posted August 31, 2011 Hello,I am VERY new to this. I'm trying to subtract two fields in ireport 4.1.1$F{CAD}$F{CMD}I tried putting $F{CAD} - $F{CMD} into a text box but that didn't work.I would like to use Designer view, but can use the XML view if you give me enough code.thanks, Link to comment Share on other sites More sharing options...
despec Posted August 31, 2011 Share Posted August 31, 2011 Like so: new java.Math.BigDecimal( $F{CAD}.doubleValue() - $F{CMD}.doubleValue()) David Link to comment Share on other sites More sharing options...
robertdseals Posted August 31, 2011 Author Share Posted August 31, 2011 In the text box? Link to comment Share on other sites More sharing options...
despec Posted September 1, 2011 Share Posted September 1, 2011 You would create a new Variable and put this within the expression field. David Link to comment Share on other sites More sharing options...
robertdseals Posted September 1, 2011 Author Share Posted September 1, 2011 startup failed:calculator_report3_1314911259878_197438: 201: unable to resolve class java.Math.BigDecimal @ line 201, column 21. Link to comment Share on other sites More sharing options...
robertdseals Posted September 1, 2011 Author Share Posted September 1, 2011 Changed to:$V{new java.Math.BigDecimal($F{CAD}.doubleValue() - $F{CMD}.doubleValue())}and still not working. Link to comment Share on other sites More sharing options...
robertdseals Posted September 1, 2011 Author Share Posted September 1, 2011 If it helps any, here's some of the XML<reportElement x="100" y="0" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$F{CAD}]]></textFieldExpression> </textField> <textField> <reportElement x="200" y="0" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$V{new java.Math.BigDecimal($F{CAD}.doubleValue() - $F{CMD}.doubleValue())}]]></textFieldExpression> </textField> Link to comment Share on other sites More sharing options...
robertdseals Posted September 2, 2011 Author Share Posted September 2, 2011 I had the fields and the variable set to "sting". I'm assuming I need to set it to "double" or something else? Link to comment Share on other sites More sharing options...
despec Posted September 2, 2011 Share Posted September 2, 2011 Yep...The resulting variable should be set to bigDecimal.... David 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