Jump to content
We've recently updated our Privacy Statement, available here ×

Can't sum product of group variables


chaddn

Recommended Posts

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

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

 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

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

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 said


Hope this will help this time,
sanda

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...