Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: select specific row of data Post Reply Post New Topic
Author Message
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Topic: select specific row of data
     Posted: 20 May 2013 at 8:07am
i have a field that i'm using a date selection on to choose which row of data to show currently. it works as it should. However, if i want to choose the row above it for another formula how would i do that?

for example here is what my field looks like


rate  date
1        1/01/2001
2        1/01/2003
3        2/05/2003
4        5/15/2010
5        5/14/2013

i can write a simple formula to show me the most recent one (if ({date}) > some date then {rate}) which is what i have but what would i do to see the row above it?


thank you in advance
IP IP Logged
joeg1962
Newbie
Newbie


Joined: 01 Mar 2013
Location: United States
Online Status: Offline
Posts: 35
Quote joeg1962 Replybullet Posted: 20 May 2013 at 8:24am
Can't you do {date} < some_date and then do a max summary?
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 20 May 2013 at 8:30am
I'm not sure that will work or how to do it actually. what my client is looking for is if an employee got a raise which would be indicated by the active date beside the rate then they want to see the difference it makes in yearly salary.

i can get the employee salary by taking the active rate * default hours * pay frequency.

the only thing i'm not sure of is how to make a similar formula to say
rate before the active rate * default hours * pay frequency.
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 20 May 2013 at 8:45am
ok, so i was over thinking for a minute. i have this

maximum({date}, {group}) which returns the latest date but i'm having trouble figuring out the 2nd most recent date.

any help would be great.


Thank you!
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 20 May 2013 at 10:45am
if your data is ordered by date, and you want the rate from the date before the current line, there is the PREVIOUS() function which will look back 1 row in the dataset.

There is 1 caveat that I am aware of...namely, it doesn't care about groupings, so extra caution is needed for that case.

Hopefully this is what you are looking for.
IP IP Logged
bwsanders
Senior Member
Senior Member


Joined: 05 Sep 2012
Location: United States
Online Status: Offline
Posts: 177
Quote bwsanders Replybullet Posted: 21 May 2013 at 2:30am
i'm trying to see if PREVIOUS() will be the way for me to get what i need but i'm not really seeing it work. not every employee will have multiple rates so the previous function seems to be pulling the record above that may not be for that employee.
IP IP Logged
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