Joined: 11 Dec 2007
Online Status: Offline
Posts: 8
Topic: Running Variable? Posted: 03 Nov 2009 at 1:55pm
Hi all, I'm using CR 2k8... My report outline looks something like:
Report Header
Page header a
Page header b
Group Header #1a
Group Header #1b
Details
Group Footer #1a
Group Footer #1b
Report Footer
Page Footer
----
In the details section I have two formula fields. One is an sum of two items in that same detail (Plus/Minus_, and the second is a running average of the Plus/Minus.
How can I setup a third item, that would start at 100 when the report is run, and increment based on the average field?
For example, if the average field is > 1 the third item would increase by 1, to 101..
Joined: 11 Dec 2007
Online Status: Offline
Posts: 8
Posted: 04 Nov 2009 at 7:46am
@FrnhGLI.. Thank you for that.. I have amended your forumla slightly.. But apperantly have gotten the syntax of CR incorrectly.. Can you point at what I'm goofing?
global numbervar nIncrement:=nIncrement +
(if {#RTotal0}<(-20) then -2 else 0);
(if {#RTotal0}<(-15) and {#RTotal0} > (-20) then -1.5 else 0);
(if {#RTotal0}<(-10) and {#RTotal0} > (-15) then -1 else 0);
(if {#RTotal0}<(-05) and {#RTotal0} > (-10) then -.5 else 0);
nIncrement;
Joined: 22 May 2009
Online Status: Offline
Posts: 347
Posted: 04 Nov 2009 at 7:59am
Try this:
global numbervar nIncrement:=nIncrement - (if {#RTotal0}<=(-20) then 2 else if {#RTotal0}<=(-15) and {#RTotal0} > (-20) then 1.5 else if {#RTotal0}<=(-10) and {#RTotal0} > (-15) then 1 else if {#RTotal0}<=(-05) and {#RTotal0} > (-10) then .5 else 0); nIncrement;
I'm not sure if you need the parenthasis around the negative numbers, though, so if you get another error, try removing those.
Also, I only put the equal signs in because your formula was leaving out what to do if {#RTotal0} is equal to those numbers. You may need to play around with this to suit your needs.
Joined: 11 Dec 2007
Online Status: Offline
Posts: 8
Posted: 04 Nov 2009 at 8:27am
Got it:
global numbervar nIncrement:=nIncrement +
if {#RTotal0}>(20) then -2
else if {#RTotal0}>(15) and {#RTotal0} < (20) then -1.5
else if {#RTotal0}>(10) and {#RTotal0} < (15) then -1
else if {#RTotal0}>(05) and {#RTotal0} < (10) then -.5 else 0;
nIncrement;
My last remaining question.. How can I have this formula work on the last value of #RTotal0 only?
That is it averages items in the detail. But it repeats for each record in the group. Where that formula is concerned, I'm only interested in the final value. The result..
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