Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Running Summary on a formula field Post Reply Post New Topic
Author Message
H0P5
Newbie
Newbie


Joined: 20 Jun 2007
Online Status: Offline
Posts: 14
Quote H0P5 Replybullet Topic: Running Summary on a formula field
    Posted: 21 Nov 2007 at 4:13am
Hi There
 
I have a formula that says..
 
if ext = "yes" then formula = "new rate" * "hours"
if ext = "no" then formula = "old rate" * "hours"
 
I then want a running summary for the result.
The formula works fine in the group headers, but i am unable to select this formula as a report footer.
 
I am sure I am being silly, can anyone help me where I am going wrong please?
 
H0P5
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 21 Nov 2007 at 5:51am
You're not being silly.  It's a very common constraint of Crystal that some formulas simply can't be aggregated.  This is especially true where running totals get involved.  (The reason for this has to do with the order in which Crystal calculates such things.)

But, you can certainly create a custom formula to do the work for you.  Try something like:

If ext = "yes" then
formula = Sum ({NewRate}*{Hours})
Else
formula = Sum({OldRate}*{Hours})


IP IP Logged
H0P5
Newbie
Newbie


Joined: 20 Jun 2007
Online Status: Offline
Posts: 14
Quote H0P5 Replybullet Posted: 21 Nov 2007 at 8:29am
Excellent thanks for your reply!
 
That looks very much like the formula I am already using.. I do not understand where I can place this formula to obtain the results I seek :(
 
Please help,
 
thanks ever so much!
H0P5
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 26 Nov 2007 at 10:10am
Hmm.  I think I led you somewhat astray.

To do a running total, create a global variable.  Actually, in this case, create two global variables.  We'll call them NewRateTotal and OldRateTotal.

Create a formula, that should look something like:

WhilePrintingRecords;

Global NumberVar NewRateTotal;
Global NumberVar OldRateTotal;

If {ext} = "yes" Then
NewRateTotal = NewRateTotal + {NewRate}*{Hours}
Else
OldRateTotal = OldRateTotal + {OldRate}*{Hours};


Then, in your group footer, you can put something like:

WhilePrintingRecords;

Global NumberVar NewRateTotal;
Global NumberVar NewRateForReport;

NewRateTotal;
NewRateForReport = NewRateForReport + NewRateTotal;
NewRateTotal = 0;


And, another one for OldRateTotal.  Then, in your report footer, put:

WhilePrintingRecords;

Global NumberVar NewRateForReport;

NewRateForReport;




However, given your specific requirements, there may be an even easier way.  Try in your report footer:

SUM (IIF({ext} = "yes",{NewRate}*{Hours},{OldRate}*{Hours}))

That will sum everything up in one grand total.  (If you want to just the NewRate sum, just replace the OldRate bit with 0, and vice versa.)


IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.020 seconds.