Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: 2nd last commend Post Reply Post New Topic
Author Message
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Topic: 2nd last commend
    Posted: 30 May 2012 at 5:57am
Hi all,

I am currently working on a report, given the last comment made on each case. However, every once in a while, we check if these cases are still correct. We place a comment in the 'Comment' table, saying 'Folder examined'.

However, if this is the case, I don't want to show the last comment, but the second last comment. I've tried nthlargest(2, {comment.comment}). But then he is just picking up the comment that starts with a Z or something. Is there a way to look at the comment date, determine if the comment is only 'Folder examined', and based on that show either the last comment or the second last comment?

Thanks in advance

Kind regards,

Gerben
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 30 May 2012 at 6:30am
if the records are consecutive, you might try Prior or is Previous...but I don't know how nthlargest works.
 
my personal favorite answer is to write a stored proc (which I always do), then you are in complete control of what value is written.
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 30 May 2012 at 10:16pm
I've never worked with stored proc before... How would I be creating this? Could you help me with that? Everything I know about Crystal is what I found out myself and what I've been told here

Thanks in advance
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 31 May 2012 at 12:59am

A way to do it without prior/next and without a stored proc would be to merge your comment date with the comment so the nthlargest can work correctly;

Merge
totext(comment.date,"yyyyMMdd")
&
table.comment
 
Comment
if "Folder Examined" in (nthlargest(1,merge,table.casegroup))
then mid(nthlargest(2,merge,table.casegroup),9)
else mid(nthlargest(1,merge,table.casegroup),9)
 
It might take abit of tinkering as I haven't tested it but that should get you what you need.
 
I too would create a stored proc for something like this though.
 
Regards,
Ryan.


Edited by rkrowland - 31 May 2012 at 4:31am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 31 May 2012 at 3:33am
Never used nthLargest, but seems like a nifty solution Ryan.
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 31 May 2012 at 4:44am
Thanks for your help Ryan. I do have 1 question though

if "Folder Examined" in (nthlargest(1,merge,table.casegroup))

What do you mean with table.casegroup? the field I am grouping on?
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 31 May 2012 at 4:56am
That's the one, if you're not already grouped by "case" you'll need to for this to work.
 
Regards,
Ryan.
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 31 May 2012 at 5:09am
I'm getting the message "There must be a group matching this field", highlighting
(nthlargest(1,{@merge},{@03. C.D.#})
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.