Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula creation Post Reply Post New Topic
Page  of 2 Next >>
Author Message
El22
Newbie
Newbie
Avatar

Joined: 07 Apr 2011
Online Status: Offline
Posts: 10
Quote El22 Replybullet Topic: Formula creation
     Posted: 07 Apr 2011 at 12:40am

Hello,

I am relatively new to Crystal and would like any assistance if possible to a solution I need to find.
 
I am trying to create for formula to track account changes in my business, basically the database lists effective from and to dates for every single change made, however I just want to monitor specific changes to location.
 
What I am trying to create is a report which tells me, for any accounts, which Location(s) it has been in previously and when it was moved from/to different locations.
 
Basically, whenever a location changes on my sequential list (see below) it is the "Date from" which I want to record:
 
 
Acct #               Location                    Date from                       Date To
4100 Location 1 29/09/2007  19:05:00 07/09/2008  21:07:53
4100 Location 1 07/09/2008  21:07:53 07/09/2008  21:07:54
4100 Location 1 20/01/2009  14:01:00 02/07/2010  08:14:51
4100 Location 2 02/07/2010  08:14:51 05/10/2010  17:33:06
4100 Location 3 05/10/2010  17:33:06 11/10/2010  09:19:34
4100 Location 4 11/10/2010  09:19:34 23/10/2010  22:49:49
4100 Location 4 04/04/2011  16:14:53 06/04/2011  18:52:28
4100 Location 5 06/04/2011  18:52:28 31/12/2999  00:00:00
 
So with Account 12345 I would need a formula to identify the first "Date from" when the location changes. I am at a loss at where to start really, but I think it would read something like: if the location changes then use the Date from in the first record of the location change.
 
Any advice would be great!
 
Thanks


Edited by El22 - 07 Apr 2011 at 12:51am
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 07 Apr 2011 at 3:02am
You want to create a condition for font coloring.
In this case, right-click Date From detail field --> format field --> font tab --> create new formula on Font color

Here you want a different color everytime the location changes.

That is the same as saying "if the location in this record is not the same as the location in the previous record, then my record must have changed"

This relies on you sorting your data by location to work correctly (logically).
IP IP Logged
El22
Newbie
Newbie
Avatar

Joined: 07 Apr 2011
Online Status: Offline
Posts: 10
Quote El22 Replybullet Posted: 07 Apr 2011 at 3:25am
Thanks for your reply. The outcome I wanted was not to colour these instances, but only select these instances. So I would want my list only to consist of these "first" location changes, along with the date from.
 
I would need to write a formula which identifies just these dates, as opposed to colors them. So every instance of the location after the initial changed location would need to be omitted.
 
HTH
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 07 Apr 2011 at 3:49am
You can use a selection formula to accomplish that.
It'll basically be the same formula except written as a record selection formula. Instead of coloring the ones you want, you only show the ones you want.

Edited by Keikoku - 07 Apr 2011 at 3:50am
IP IP Logged
El22
Newbie
Newbie
Avatar

Joined: 07 Apr 2011
Online Status: Offline
Posts: 10
Quote El22 Replybullet Posted: 07 Apr 2011 at 4:01am
Yes, and it is getting an idea of what this formula may look like which is what I am after.
 
Like I said, I'm quite new to Crystal Ermm
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 07 Apr 2011 at 6:05am
Oh.
Try this selection formula:


table.dateField <> previous({table.dateField})
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 07 Apr 2011 at 6:12am
Previous() cannot be used as a select criteria
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 07 Apr 2011 at 6:45am
Oh.
Ok, then here's another option:

Open up section expert, and for the "suppress (no-drill down)" option create a formula that says

table.location <> previous({table.location})

It will then suppress all records where the locationis the same as the record before, showing only the first record that changed locations.



Edited by Keikoku - 07 Apr 2011 at 6:46am
IP IP Logged
El22
Newbie
Newbie
Avatar

Joined: 07 Apr 2011
Online Status: Offline
Posts: 10
Quote El22 Replybullet Posted: 07 Apr 2011 at 9:27pm
This is all really useful help.
 
I have taken your formula Keukoku, and it seems to exclude every first record, as opposed to selecting it. I tried ammending it to this formula:
 
table.location = next ({table.location})
 
This gets me closer to the expected outcome, however it selects the most recent date for each location change, as opposed to the first one. Any ideas?
 
Thanks again.

 
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 08 Apr 2011 at 2:40am
A suppression formula does what its name suggests: suppresses items (which for some reason I had mixed up with selections)

The formula I wrote down should be

"table.location = previous(table.location)"

So it's saying "if it's the same as the one before, don't show it"

In your case, you're saying "if it's the same as the next one, don't show it". So if you think about it, it makes sense that you're getting the most recent change as opposed to the earliest change.

Edited by Keikoku - 08 Apr 2011 at 2:41am
IP IP Logged
Page  of 2 Next >>
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