Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Calculate Change From Previous Records Post Reply Post New Topic
Author Message
YrdiMn98660
Newbie
Newbie
Avatar

Joined: 05 Aug 2009
Online Status: Offline
Posts: 1
Quote YrdiMn98660 Replybullet Topic: Calculate Change From Previous Records
    Posted: 05 Aug 2009 at 11:49am

Hello,
Using detail data similiar to the example below, I am trying to report the change on the Amount field from the 3rd record prior to current (4 weeks) and am struggling on a formula to acheive this. Any help is appreciated.

Item       Date           Amount     1WkChg      4WkChg
1001      01/01/09    100.00            0.00            0.00
1001      01/08/09    100.00            0.00            0.00
1001      01/15/09    200.00        100.00            0.00
1001      01/22/09    200.00            0.00        100.00
1001      01/29/09    300.00        100.00        200.00
1001      02/04/09    350.00          50.00        150.00

Each row is a weekly snapshot of the progress of the item that needs to show current value and difference in value of the same item previous week and 4 weeks ago. The first 3 weeks would produce 0 as no change and week 4 would subtract current week amount from the "3rd previous" record.

I use something like this for the 1WkChg column:
If Previous({Item}) = {Item}
then ({Amount} - Previous({Amount})) else 0
 
Is it possible to use this same logic and get the "3rd Previous({Item}) ??
 
Thanks
 
YM
 
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 05 Aug 2009 at 1:25pm
what comes to mind is setting some shared variables, one for the item and one for the value you are tracking, you would probably need a counter of some sort so that the report knows when it can start comparing.
 
I haven't done this, and can't think of any code off the top of my head, but it is the concept that matters....  It is doable, it is just not going to be as easy as using the Previous function.
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.016 seconds.