jbessmer Posted August 31, 2021 Share Posted August 31, 2021 Hi Everyone,I'm a newbie and attempting to divide a BigDecimal field (bdfield) by a String field (strfield) in Jaspersoft Studio.I've tried about 2 dozen approaches based on what I've read on these and other forums, but haven't been successful. Does anyone have a preferred approach?Edit: Here are some approaches I've tried:$F{bdfield}.divide(Integer.parseInt($F{strfield})).setScale(2, RoundingMode.CEILING)$F{bdfield}.divide(new Integer($F{strfield})).setScale(2, RoundingMode.CEILING)$F{bdfield}.setScale(2, RoundingMode.CEILING) / new Integer($F{strfield})$F{bdfield}.doubleValue() / new Double($F{strfield})$F{bdfield}.doubleValue() / new Integer($F{strfield})$F{bdfield}.doubleValue() / Double.parseDouble($F{strfield}) Here is the error on the last one:Double.parseDouble cannot be resolved to a type value = ((java.math.BigDecimal)field_bdfield.getValue()).doubleValue() / new Double.parseDouble(((java.lang.String)field_strfield.getValue())); Thanks for taking a look, Link to comment Share on other sites More sharing options...
gustavofarias Posted August 31, 2021 Share Posted August 31, 2021 you should put the expression that makes this calculation, and the error you are getting. Also, put 3 or 4 of the dozen things you tried. Link to comment Share on other sites More sharing options...
jbessmer Posted August 31, 2021 Author Share Posted August 31, 2021 thank you gustavofarias, I've added 6 Link to comment Share on other sites More sharing options...
gustavofarias Posted August 31, 2021 Share Posted August 31, 2021 and the error? Is it compilation error ou runtime error? Link to comment Share on other sites More sharing options...
yama818 Posted August 31, 2021 Share Posted August 31, 2021 I solved it with the following formula.$F{bdfield}.divide( new BigDecimal($F{strfield})[/code]I hope this is helpful. 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