When summing a variable I am only getting the last value of the variable.

0

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?

amartin_2's picture
Joined: Mar 4 2015 - 5:18am
Last seen: 5 years 2 months ago

1 Answer:

-1

You need to create your variables with >>> reset type at group level <<<< to display group related calculation in the group footer section of your report.

tchen's picture
64375
Joined: Feb 27 2008 - 7:33am
Last seen: 19 hours 41 min ago
Feedback
randomness