Solved

# Variable Value dependent on a running sum

Posted on 2013-05-13
337 Views
I am using Crystal Reports 8.  I have a select case statement that calculates a point value:

Global numberVar  Points:=0 ;
Select {LaborDtl.ExpenseCode}
case "TA0":
Points := 0
case "TA1":
Points := 1
case "TA5":
Points := .5
case "TABD":
/* NEED SOME HELP HERE******/
default:
Points := 0

when I get to the case "TABD" I need to assign the points based on the running sum of points for the employee I am processing.

if running sum = 1, then points s/b = 6
if running sum = 2, then points s/b = 5
if running sum = 3, then points s/b = 4
if running sum = 4, then points s/b = 3
if running sum = 5, then points s/b = 2
if running sum >= 6, then points s/b = 1

How can I accomplish this?
0
Question by:ndornack
• 2

LVL 100

Expert Comment

ID: 39162467
Are you calculating a value for a running total and trying to use the running total in the calculataion?

WHat you want will be done like
(
If {#RunningTotal} = 1 then
Points := 6
Else If {#RunningTotal} = 2 then
Points := 5
Else If {#RunningTotal} = 3 then
Points := 4
Else If {#RunningTotal} = 4 then
Points := 3
Else If {#RunningTotal} = 5 then
Points := 2
Else If {#RunningTotal} = 6 then
Points := 1
)

You could also try using
7 - {#RunningTotal}

mlmcc
0

Author Comment

ID: 39162547
This is what I have now, and I am getting the ERROR:

"One of operands is a running total field which is using this formula"

Global numberVar  Points:=0 ;
Select {LaborDtl.ExpenseCode}
case "TA0":
Points := 0
case "TA1":
Points := 1
case "TA5":
Points := .5
case "TABD":
(
if {#PointsTotal} =  1 then
Points := 6
else if {#PointsTotal} = 2 then
Points := 5
else if {#PointsTotal} = 3 then
Points := 4
else if {#PointsTotal} = 4 then
Points := 3
else if {#PointsTotal} = 5 then
Points := 2
else if {#PointsTotal} = 6 then
Points := 1
)
default:
Points := 0
0

LVL 100

Accepted Solution

mlmcc earned 500 total points
ID: 39162671
If you are trying to use this as the basis for the PointsTotal running total, you can't.

I know statements like  a := a + 1 make sense (sort of) in a program, but a running total cannot refer to itself.
mlmcc
0

## Featured Post

### Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…