amartin_2 Posted March 4, 2015 Share Posted March 4, 2015 I am trying to make Jaspersoft Studio calculate a Markdown for the contents of the report. Basically, I need to first divide the price by the price qty (2 for $3.00 would give me $1.50 unit price). I then do the same thing for the regular retail (1 for $2.00 would give me a $2.00 unit price). I then would subtract the regular unit price from the discounted unit price to get my markdown ($0.50).I am using MySql. Both active price and regular price are set as Decimal and the price qty is set to integer.First I create two variables and use the following expressions to convert the integer values to BigDecimal. This seems to work fine, when I drag the variable into the report it shows the same value as the corrosponding field. So far so good.$V{Active Unit}.valueOf( $F{Price Qty} )$V{Reg Unit}.valueOf( $F{Reg Retail Unit} )The next two variables I create then divide a field by that variable. (I am at this point finding unit price 2 for $1.00 show as .50 this way). These are returning null.$F{Price}.divide($V{Current Unit Price})$F{Reg Retail}.divide($V{Regular Unit Price})I then subtract the two newly created variables from each other (This is to find out my markdown for discounted items .75 - .50 is a .25 markdown per item). This is also returning null, although I don't know if this is because of the previous null or if it is its own problem.$F{Reg Retail}.divide($V{Regular Unit Price})Any ideas what I am doing wrong? I know very little java, I am using this through Jaspersoft Studio. Based on what I have read, I believe I have constrcuted this correctly. Anyone have any ideas? Link to comment Share on other sites More sharing options...
amartin_2 Posted March 5, 2015 Author Share Posted March 5, 2015 Based upon other questions that seem similar, I have tried the following formula. This time I am using the fields directly instead of a variable. I am still getting null. This should be as simple as 3.00/2 and display 1.50 however it is not working it still shows null. I have confirmed that the fields contain values for all fields.new Double($V{UnitPrice}.doubleValue() == 0 ? 0 : ($F{Price Qty}.doubleValue()/$F{Price}.doubleValue())) 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