Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: formula selct and sort Post Reply Post New Topic
Author Message
nitrotech
Groupie
Groupie


Joined: 30 Jan 2013
Location: United States
Online Status: Offline
Posts: 42
Quote nitrotech Replybullet Topic: formula selct and sort
    Posted: 18 Nov 2015 at 9:04am
I want to sort on table that holds rates.
The table has the current rate and past history of rates each rate has a start and end date

What I need is to pull the current rate to a variable and then the previous rate to a variable so I can use them in a formula

any ideas?

Thanks
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3701
Quote hilfy Replybullet Posted: 19 Nov 2015 at 4:38am
Assuming that you're grouping on account or something of the sort, sort the data on the start date descending. Then you'll use a couple of formulas something like this:

{@InitVars}
WhilePrintingRecords;
NumberVar currentRate := 0;
NumberVar prevRate := 0;

Put this formula in the Account group header - nothing will display, but we need it there to initialize the variables.

{@CalcRates}
WhilePrintingRecords;
NumberVar currentRate;
NumberVar prevRate;
if currentRate = 0 then
currentRate := {rate field}
else if prevRate = o then
prevRate := {rate field};

Then you'll need a third formula to do your actual calculation. It will look something like this:

{@RateChange}
WhilePrintingRecords;
EvaluateAfter({@CalcRates});
NumberVar currentRate;
NumberVar prevRate;
<do your calculation here>

NOTE: Because of the way these need to be calculated, you may only be able to use the final formula in the Account group footer.

-Dell

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.031 seconds.