Jump to content
Changes to the Jaspersoft community edition download ×

How to total variables in a table


brossow
Go to solution Solved by brossow,

Recommended Posts

I'm sure this is a basic question, but I'm new to iReport and can't figure this out or find an appropriate answer by searching. (Trust me, I didn't want to have to ask.)

In a nutshell, I have a 4-column table using a data source that provides item description, unit price and quantity.  I have created a variable $V{ItemTotalPrice} that multiplies unit price by quantity to get the total per-item price, and that works great (4th column).  What I can't figure out is how to get a total of $V{ItemTotalPrice} for the entire table (i.e. total of the 4th column).  I tried creating a new variable $V{GrandTotal} that uses calculation type Sum and the variable expression is  $V{ItemTotalPrice} and evaluation time Report (also experimented with other options).  I used the variable in a textField in the 4th column in the table footer.  (I also tried putting it in the column footer band.) No matter what I do, it only seems to return the value of the last line item in the Detail band and not the total from the table.  What am I missing?  The table below is what I'm trying to get. Thanks for your help and patience with a clueless newbie!

Description   Unit Price   Qty   Total PriceItem 1            $ 5.00    3        $ 15.00Item 2            $ 2.00    5        $ 10.00Item 3            $ 8.00    2        $ 16.00Total                                $ 41.00

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

  • Solution

Wouldn't you know that after struggling with this for hours, I found a solution just minutes after finally asking for help. I changed the Reset Type on the $V{GrandTotal} variable from None to Report and it made all the difference. Hope my inexperienced fumbling helps someone else at least. :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...