Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Cannot Summarize a Formula Post Reply Post New Topic
Author Message
bshort1023
Newbie
Newbie
Avatar

Joined: 18 Jan 2012
Location: United States
Online Status: Offline
Posts: 18
Quote bshort1023 Replybullet Topic: Cannot Summarize a Formula
     Posted: 19 Nov 2014 at 6:46am
My initial problem was that when I summed detail lines in the report footer it was also summing lines that I was suppressing.  I added a formula that used the same logic as the suppression so that if the detail was suppressed then the formula would = zero.  If not it would equal the line total.  This works.  The problem is that I it will not allow me to summarize that formula.

Here is the formula:

IF {QuoteDtl.DisplaySeq} = 1.000 THEN
    {QuoteDtl.SellingExpectedQty} * {@LinePriceWithDiscount}
ELSE
    IF (ToText((Previous({QuoteDtl.DisplaySeq})),0) = {@SalesKitLine}) THEN 0 ELSE {QuoteDtl.SellingExpectedQty} * {@LinePriceWithDiscount};

If I remove the "ToText" portion of the formula then it does allow me to summarize it.

Any thoughts?
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 Nov 2014 at 7:50am
you cannot summarize anything using a previous() or next() function.
Two ususal solutions.
1. Using shared variable formulas.
YOu need 3 of these (per group)
2. Use running totals.
I prefer RTs when possible
I think this will work for you.
create one formula as
//discount --or whatever you want
{QuoteDtl.SellingExpectedQty} * {@LinePriceWithDiscount}
 
make a running total (using field explorer)
Name=whatever
type=sum (assuming you want a sum)
evaluate=on change of field - select QuoteDtl.DisplaySeq
reset=never (unless you need group totals)
 
Only thing I am not sure about is your @SalesKitLine formula
 
 
NOTE: Both solutions require you place the summary in the detail and or footer. Neither work in a header.
 


Edited by DBlank - 19 Nov 2014 at 7:52am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 Nov 2014 at 7:30am
I second DBlank's answer. I like shared variables myself...for no good reason running totals confuse me...but they both do about the same thing.

the reason that CR can't summarize, is that when it is reading the data for the aggregate phase (avg, sum, count) it doesn't know which record is going to previous or next, and so it can't summarize a formula like this.

If all the data the you wanted to summarize or use in the logic was on 1 line, and then CR can do it. Add in logic when you want to pick and choose which values to include and CR can no longer summarize and you need to use of the 2 methods mentioned by DBlank.

HTH
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