I have a variable that performs some math on some database fields.
($F{Price}.doubleValue()/$F{Price Qty}.doubleValue())*$F{Qty Sold}
(($F{Reg Retail}.doubleValue()/$F{Reg Retail Unit}.doubleValue())-($F{Price}.doubleValue()/$F{Price Qty}.doubleValue()))*$F{Qty Sold}
These variables perform perfectly and give me the values I need. The first tells me the price per unit of an item and multiplies it against the total sold to give me total sales for the unit. The second gives me the difference between the regular price and the discounted price and multiplies it against total sold to give me the markdown amount, or the amount the sale cost me.
My problem occurs when I try to sum these variables in the Group Footers. I drag the variable into the footer and when the report runs it only shows me the last value of the calculation, but if I drag a field into the Group Footer band it asks me if I want to sum, count, etc. the field and the fields will sum properly. I am running into the same problem when I try to put a variable I have created into a crosstab. If I put fields from the database in the crosstab they calculate just fine but when I put variables I have created in Jaspersoft Studio that work correctly in the body of the report, the numbers come out all screwy. Anyone know what I am doing wrong?