2006 IR Open Discussion Posted August 19, 2006 Share Posted August 19, 2006 By: Erik Romson - romson calculating percent in detail band 2003-06-05 14:03 Hi, I'm trying to do the following: group1 text value ratio ------------------------- str1 1 33% str2 2 50% str3 1 33% sum: 4 group2 text value ratio ------------------------- str1 1 25% str3 3 75% sum: 4 group3 text value ratio ------------------------- str2 1 100% sum: 1 summary: str1 2 22% str2 3 33% str3 4 44% The problem is to calculate the actual percent. I cant get the group's summation so that I can divide it with the row value. Im able to push and pop the values for each row but the evaluationTime=report seems to trigger randomly etc. Can someone explain to me how to do this and I would be very grateful. Regards erik By: Albert L. - looks RE: calculating percent in detail band 2003-06-05 17:34 Hi, You may have to do the pre-calculation and store it back to the sql table before reporting it. I think (pls correct me if wrong) JasperReports is not a multi-pass engine where you may perform calculation requiring to scan thru all rows before printing begins. Albert By: Albert L. - looks RE: calculating percent in detail band 2003-06-06 05:48 Hi, Perhalps you would like to use scriptletClass to explore other possibility, such as having each row to fetch the total of the current group for percentage computation. However, I've not done any scriptletClass implementation before but I think it's not difficult to implement it - take a look at the scriptletClass demo. Albert By: Erik Romson - romson RE: calculating percent in detail band 2003-06-05 23:58 Hi, Can't do that. I'm using groups and counting each row that has certain text and calculate a sum. Then I would have to add a whole new table. What I'm a bit disturbed about is that the a variable that has evaluationTime=report is calcualted in a random order. For example. I would solve this by: First with evaluationTime=now, print table First I create a stack that has the values for each row. group1 text value ratio ------------------------- str1 1 -> "push value to stack" str2 2 -> "push value to stack" str3 1 -> "push value to stack" sum: ? Now at evaluationTime=report. Now we have the total summary (which is 4) group1 text value ratio ------------------------- str1 1 33% "pop from stack/4" str2 2 50% "pop from stack/4" str3 1 33% "pop from stack/4" sum: 4 But the stack.pop is called at a random order and not as they were pushed. This I do not really understand. By: Teodor Danciu - teodord RE: calculating percent in detail band 2003-06-15 13:10 Hi, The order of "pop" operations is not guaranteed. But you can use a Map instead of a stack and employ the REPORT_COUNT or GroupName_COUNT value as the key. I hope this helps. Teodor By: Mihir Parekh - mihirparekh RE: calculating percent in detail band 2003-07-17 21:51 Hello, How do i implement this? Do I need to create the Map in the scriptlet or I can define the map as variable. If I define the map as a variable, how can I store the values in the map and how can I retrieve those stored values? Thank you, Mihir By: Mihir Parekh - mihirparekh RE: calculating percent in detail band 2003-07-23 23:38 Hello, Just wondering if some of the HashMap like specificGroupBoundTexts can be made SequencedHashMap ( from jakarata Collections) to guarantee ordering. thanks mihir 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