jme14 Posted February 5, 2008 Share Posted February 5, 2008 I want to create some kind of timesheet with data of multiple employees. I have created a group on employee lastname. To calculate a subtotal per employee I have created a variable V_SUM_PER_EMP:- variable class type: java.math.BigDecimal- calculation type: sum- reset type: group- reset group: lastname- increment type: none- variable expression: $F{minutes} This works fine. Now, I want to create a summary total to calculate the sum of all minutes for all employees on report. Therefore I can simply create another variable, like V_SUM_PER_EMP with reset group = report.BUT in my report I want to compute the sum of minutes on report, based on variable V_SUM_PER_EMP (because in my real life report the variable expression of V_SUM_PER_EMP is more complex then in this example), so I created a new variable V_SUM_PER_EMP_REPORT:- variable class type: java.math.BigDecimal- calculation type: sum- reset type: report- reset group: -- increment type: none- variable expression: $V{V_SUM_PER_EMP} The result value (printed in the summary band) of this calculation is NOT right. The first group subtotal: 65.92The second group subtotal: 22.42The report total: 611.42 How can I calculate the right value? Link to comment Share on other sites More sharing options...
vinays84 Posted February 5, 2008 Share Posted February 5, 2008 The reason this is occurring is because you are summing up a value that is a sum. As a result, you are summing the sum at each step. For example, if your first variable was v1 and the variable second v2, which summed of v1, you'd have: v1 v20 02 22 47 11-------0 111 12--------0 123 15 Where the "--"'s represent new groups. As you can see v2 finishes off at 15 rather than your desired result of 11. The direct solution is the one you suggested yourself, to create the second variable with the same variable expression as the first, but with a reset type of report. If this doesn't work due to your complex definition of the first variable, please post this complex expression, as we can't troubleshoot it blind. Link to comment Share on other sites More sharing options...
jme14 Posted February 5, 2008 Author Share Posted February 5, 2008 Thanks for you reply. For each group, I calculate a subtotal with expression:$V{v_sum_amount_1}.min( $V{v_sum_amount_2} ).multiply( $F{factor} ) this means:subtotal := minimum(amount_1, amount_2) * factor Example group:a_1 a_2 charge---- ---- -----------69,0 48,5 € 2.968,0322,9 34,0 € 985,4238,5 22,8 € 1.653,96---- ---- ------------130,4 105,3 € 5.607,41 ==> € 4.527,90 (factor = 43) This factor can be different per group (72.5 or 43) amount_1 stands for the total hours per employee (130.4) in January 2008amount_2 stands for the maximum amount to charge per employee (105,3) in January 2008The subtotal value = min(130.4, 105.3) * 43 = 105.3 * 43 = 4527.90 So, I want to calculate the sum of $V{v_sum_amount_1}.min( $V{v_sum_amount_2} ).multiply( $F{factor} ) on report. Any ideas? Regards,JanM Link to comment Share on other sites More sharing options...
jme14 Posted April 4, 2008 Author Share Posted April 4, 2008 I don't have any clue yet...Any ideas? I am still interssted. Regards,JanM 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