Solved

Conditional Running Total

Posted on 2013-05-13
2
296 Views
Last Modified: 2013-05-14
I have a crystal report where I am trying to do the following:

date              code             points calculated points      accum
04/26/13      TALP        0.5      0.5      0.5
04/29/13      TATD      1      1      1.5
04/30/13      TANN      0      5.5      7
05/01/13      TATD      1      1      8
05/02/13      TANN      0      1      9
05/03/13      TAUF      1      1      10
05/04/13      TALP             0.5      0.5      10.5

If the code is TANN, and the accumulated points are < 7, then the points to use for that TANN code are (7-accum), otherwise the points to use for the TANN code is 1.

It seems like I cannot have a running sum formula refer to itself.

Is there anyway to do this.  See attached example in an Excel file.
calcTANN.xls
0
Comment
Question by:ndornack
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39163592
Sure with a manual running total

In the report header add a formula to declare the variables

WhilePrintingRecords;
Global NumberVar TotalPoints;
""

In the detail section add a formula where you want CalcPoints displayed
WhilePrintingRecords;
Global NumberVar TotalPoints;
Local NumberVar CalcPoints;

If {CodeField} = "TANN"  AND TotalPoints< 7 then
     CalcPoints := 7 - TotalPoints
Else If {CodeField} = "TANN" then
     CalcPoints := 1
Else
     CalcPoints := {PointsField};
TotalPoints:= TotalPoints+ CalcPoints;
CalcPoints

To display the new total points
EvaluateAfter({@CalcPoints});
WhilePrintingRecords;
Global NumberVar TotalPoints;
TotalPoints

mlmcc
0
 

Author Closing Comment

by:ndornack
ID: 39166047
Works great!  Thanks.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

680 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question