My company is new to jasper reports and I'm trying to create what I believe to be a relatively simple report but I'd like to know the best way to approach this. I've created a relatively simple query to return sales for the current year by account.
Example:
Account Name | YTD Sales |
Account A | 1,234 |
Account B | 3,456 |
Account C | 789 |
Now I want to add another column for Last Year's Sales. It's simple enough to build the query, but how do I now add this as a column?
- Create a subreport for Last Year's Sales with Account as a parameter and Sales as a return variable?
- Similar to the above, but using a subdataset?
Obviously, I can do this using a complex SQL statement but I don't feel like that's the best way. (Also, I plan to add some other columns to this report that may not be so easy to do by extending a complex sql query).
Thanks for any help. I have found the documentation and Online Learning Portal to be a bit lacking for anything but the basics, so if there's any resurces out there for dealing with more complex reports that would be greatly appreciated as well.
1 Answer:
As you stated, there is more than one way to accomplish adding the additional query. For what you want, I would use a subreport.
Have you seen the online Jaspersoft Studio tutorials? http://community.jaspersoft.com/wiki/jaspersoft-studio-tutorials-archive We are adding more of them all the time, not just for product releases. In addition, if you write one (or need one) there is a link to send the team email about it. We'd love help getting more up there!
Regards,
Ilona