Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Field cannot be summarized Post Reply Post New Topic
Author Message
rusmanicai
Newbie
Newbie
Avatar

Joined: 14 Sep 2011
Location: United States
Online Status: Offline
Posts: 17
Quote rusmanicai Replybullet Topic: Field cannot be summarized
     Posted: 09 May 2012 at 3:49am
Hello,
I have this report that is calculating sales commission.
The sales rep gets a different percentage for each customer and needs to be penalized for credit notes.
I have a formula that shows the invoice amounts as positive numbers and the credit notes as negative numbers for every invoice, and placed it in the details section:
@extendedsalesprice:

if {sp_SalesRepReport.transactiontype} = "Credit Note" then
-{sp_SalesRepReport.extendedprice}
else
{sp_SalesRepReport.extendedprice}

Then I created a summary of this formula to reflect the totals per customer.
Then I created a formula that calculates commission at the customer level, and placed it in the group footer section:
@commission:

(Sum ({@ExtendedPrice}, {sp_SalesRepReport.custaccount})*{sp_SalesRepReport.Commission2})/100

So far so go, totals are right (deducting credits from the total), the commission per customer looks correct, but when I tried to summarize this formula Commission so that HR can pay the sales rep I get the famous "This field cannot be summarized". I did some research and found that you can use variables but I am new at this Crystal Report writing thing and do not know how to do that.

If someone can guide me I would appreciate it.
Thank you,
Julia.

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 May 2012 at 4:08am
if the formula manipulates the data in anyway, such as adding or subtracting it, then the aggregate functions won't work, since CR cannot summarize the data prior to display.
 
I know, sounds confusing. If you look at the data and you say if field1 = x then add field2 to a total, that can be summarized, but if you say if field1 = x then add field2 and if field1 = y then subtract field2, then CR isn't happy.
 
There is a way around this...use shared variables to keep track of your running total. Typically they come in 3's (reset, increment, display)
reset-group header
shared numbervar x:=0;
"" //hide the zero
 
increment detail section:
add to your existing formula
shared numbervar x;
  existing formula
x:= x+commission;
commission;
 
display-group footer
shared numbervar x;
x
 
HTH
IP IP Logged
rusmanicai
Newbie
Newbie
Avatar

Joined: 14 Sep 2011
Location: United States
Online Status: Offline
Posts: 17
Quote rusmanicai Replybullet Posted: 09 May 2012 at 6:08am
Hi HTH,
I created the three formulas as described below, but I have a problem with the second one (the one that increments the variable). What I typed is:

shared numbervar x;
(Sum ({@ExtendedPrice}, {sp_SalesRepReport.custaccount})*{sp_SalesRepReport.Commission2})/100)
x:= x+{@commission};
{@commission};

I also typed commission without the @ in front, it doesn't work either way.
Please let me know what am I missing.
Thanks,
Julia.
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 09 May 2012 at 6:38am
you can't use the SUM...
the commission is just a place holder as I don't the formula for calculating it.
 
what the shared variable method is doing is adding each tiny piece, every time it comes across it...it's doing the sum, just one step at a time instead of all at once.
 
You would need to adjust your logic to take that into account.
IP IP Logged
rusmanicai
Newbie
Newbie
Avatar

Joined: 14 Sep 2011
Location: United States
Online Status: Offline
Posts: 17
Quote rusmanicai Replybullet Posted: 09 May 2012 at 7:03am
I got it! I am so happy! Thanks for your help.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum