bfluensee Posted April 14, 2010 Share Posted April 14, 2010 Hi,I am new to Jasper & iReport and have a question about printing report detail not necessarily by group but by expression I guess.I have a result set with a column that has an amount for each record. My result set is already ordered by amount in descending order. Below is the desired groups.Group 1. amount greater than or equal to 1000Group 2. amount greater than 500 but less than 1000Group 3. amount greater than 100 but less than 500 Currently the reports prints out all of the detail but not grouped by amount. Is it possible to do this type of grouping by expression or is there a better way to get the desired report layout? Should I use a subreport? Thank you in advance for any advice you can give me.Post Edited by bfluensee at 04/14/2010 21:11 Link to comment Share on other sites More sharing options...
ckampshoff Posted April 15, 2010 Share Posted April 15, 2010 Hi,you can use something like this:($F{amount}.doubleValue() >= new BigDecimal(1000).doubleValue() ? "Group 1": ($F{amount}.doubleValue() > new BigDecimal(500).doubleValue() && $F{amount}.doubleValue() < new BigDecimal(1000).doubleValue() ? "Group 2": ($F{amount}.doubleValue() > new BigDecimal(100).doubleValue() && $F{amount}.doubleValue() < new BigDecimal(500).doubleValue() ? "Group 3": "Group 4")))Put thos piece of code into your "Group Expression".An other workaround is to do this in your SQL query (if you're using SQL). Create a CASE .... WHEN expression like this: (CASE WHEN amount >= 1000 THEN 1 WHEN amount > 500 AND amount < 1000 THEN 2 ... ELSE 0 END) AS SORT. If you then put $F{SORT} in your group expression it should work like you've expected.HTHChristina. Link to comment Share on other sites More sharing options...
bfluensee Posted April 15, 2010 Author Share Posted April 15, 2010 Thank you for help Christina, your first suggestion worked just fine. 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