chaddn Posted August 9, 2011 Share Posted August 9, 2011 I have a report that calculates the commission owed per sales order value based on 6 different commission rates (one rate up to $50k order, another for $50k to $100k orders, etc). There is one group in the report which is the sales order number. I use variables comm_1 through comm_6 which use an expression that evaluates the total value of the order and if true multiplies the total order value by the associated commission percentage to show the calculated commission, if false the variable is set to 0. I then stack these 6 variable fields on top of each other on the report (in the group footer) and use a print when expression in each like $V{comm_1}>(0). This part works great, it displays the appropriate commission amount based on each total order value.Next I need to sum the total of those variables in my last page footer. So I created a variable called comm_t (calculation type sum, reset type report) with a variable expression of ($V{comm_1}+$V{comm_2}+$V{comm_3}+$V{comm_4}+$V{comm_5}+$V{comm_6}). When I run the report comm_t displays a value that does not equal the sum of the commission values shown in the groups. I have no idea where it is getting the value that it is, it doesn't seem to match up with any combination of the calculated commissions.Is it possible to sum the product of group variables in a report summary? JRXML is attached, any help or hints would be greatly appreciated!Thanks,Chadd Link to comment Share on other sites More sharing options...
lknueve Posted August 9, 2011 Share Posted August 9, 2011 Try changing the Evaluation Time for the field displaying the variable to "Report" - it's currently set to "Now" - changing it to "Report" will force the variable to finish calculating before it's displayed Link to comment Share on other sites More sharing options...
chaddn Posted August 9, 2011 Author Share Posted August 9, 2011 Thanks for the reply.. I changed the variable's text field to Evaluation Time = Report and I get the same incorrect value Link to comment Share on other sites More sharing options...
lknueve Posted August 9, 2011 Share Posted August 9, 2011 The only thing left I can think of is if one of the variables is null? Like it never gets through to the variable? I could be wrong, but try updating your total variable to incorporate if any of the other variables are null, such as: ($V{comm_1}==null?0:$V{comm_1}) + ($V{comm_2}==null?0:$V{comm_2}) + ($V{comm_3}==null?0:$V{comm_3}) + ($V{comm_4}==null?0:$V{comm_4}) + ($V{comm_5}==null?0:$V{comm_5}) + ($V{comm_6}==null?0:$V{comm_6}) Link to comment Share on other sites More sharing options...
szaharia Posted August 10, 2011 Share Posted August 10, 2011 Hi,In addition to all settings already done, the resetType setting could be helpful: <variable name="comm_t" class="java.lang.Double" resetType="Report" calculation="Sum">...</variable>Regards,sanda Link to comment Share on other sites More sharing options...
chaddn Posted August 10, 2011 Author Share Posted August 10, 2011 I tried considering if the variables I'm summing are null and I still get the same incorrect value. I tried changing the reset type of comm_t to all other options and I either still get the incorrect value or just zero.Right now the data I'm testing with is only getting a value in comm_1 because all of the orders are less than $50k in this time frame. So I even tried removing all the other comm_# variables from comm_t and only had $V{comm_1} as the variable expression.. but I still get the same incorrect value. There is a jpg of the output (it's only 1 page), you can see the total Commission Due (comm_t) at the very bottom of the report of $362.04. If you add everything up it should be $532.99.This is baffling, I feel like it should just work..Thanks for all the suggestions so far.Chadd Link to comment Share on other sites More sharing options...
szaharia Posted August 11, 2011 Share Posted August 11, 2011 Hi,One more try here. :)I tested a similar situation on a local sample, and got the expected result for the following combination: for comm_i variables, resetType="Group" resetGroup="reisendenkenn" , as already set for comm_t variable, resetType="Report" incrementType="Group" incrementGroup="reisendenkenn", in order to take into account its previous values too for the textfield, evaluationTime="Report", as lknueve saidHope this will help this time,sanda Link to comment Share on other sites More sharing options...
chaddn Posted August 11, 2011 Author Share Posted August 11, 2011 Thanks for the help Sanda.. I changed the comm_t variable per your suggestions and now I get a different incorrect total of $165.66. 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