Print Page | Close Window

select last "x" number of records in database

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=7174
Printed Date: 07 May 2024 at 10:16am


Topic: select last "x" number of records in database
Posted By: JennyLynn
Subject: select last "x" number of records in database
Date Posted: 28 Jul 2009 at 9:40am
Hey everybody! I need some help coming up with a selection formula that will only display the last 6 records from a database...

Long story aside, what I have is a crystal file using an excel file outputted from another Crystal report as its database, it has 5 columns, 4 with data (month, var1, var2, var3) and another column which I added which contains the record number 1 -> x (which is 15 at this point).

Since the number of records is dynamic I can't have a formula like {record} > 10 or something simple like that, I've tried a bunch of things but every way I've thought of uses a "WhilePrintingRecords" approach and therefore isn't criteria for a selection formula.

It seems like a simple request but crystal is making it hard for me and ruining my day (like always), any help would be greatly appreciated! THANKS~!!



-------------
~~~~Jenny Lynn



Replies:
Posted By: DBlank
Date Posted: 28 Jul 2009 at 11:35am
Will suppression instead of exclusion work? Just remember that suppressed rows are still include in other summarizations.
 
You can conditionally supress your detail rows via a formula like:
RecordNumber <= Count ({tables.field that is on every row})-6


Posted By: JennyLynn
Date Posted: 28 Jul 2009 at 11:35am
nevermind, I found a workaround using the 'dateadd' function, this worked because one of my data fields was a date (well after using the cDate function, but that's additional information), the selection formula is:

{FIELD.NAME} >= DateAdd('m',-6,CurrentDate)


Sweet!

Big%20smileBig%20smileBig%20smileBig%20smile
Big%20smile

-------------
~~~~Jenny Lynn


Posted By: JennyLynn
Date Posted: 28 Jul 2009 at 11:50am
thanks for the help DBlank, that works too! Oh choices choices! LOL

-------------
~~~~Jenny Lynn



Print Page | Close Window