Print Page | Close Window

limit records of field in detail section

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19208
Printed Date: 05 May 2024 at 1:10am


Topic: limit records of field in detail section
Posted By: abdulmoiz
Subject: limit records of field in detail section
Date Posted: 03 Mar 2013 at 10:12pm
Hello,

I have a report which contains a field named Code. I am displaying this field in my details section. I need to limit the number of records displayed in this field to 3. i.e. I want to display only top 3 records in this field.



Replies:
Posted By: hilfy
Date Posted: 04 Mar 2013 at 4:23am
How do you define the top 3?  If it's based on a summary of some data (sum, count, etc.), search in the Crystal help for "Top N" and follow the instructions there.  If it's not based on a summary, try this:
 
1.  Sort the data descending on the field you're looking at.  This sort will happen inside whatever groups you already have defined.
 
2.  Create a Running Total (I'll call this {#RecCount}):
Field to Summarize:  Some key field in the details.
Type of Summary:  Count.
Evaluate: Every Record.
Reset:  On change of group - whatever the inner-most group is that the details are based on.
 
3.  Go to the Section Expert.  Click on the formula button to the right of the Suppress checkbox (DO NOT check the checkbox!).
 
4.  Enter the following formula:
 
{#RecCount} > 3
 
This should give you just the top three records in the group.
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: DBlank
Date Posted: 04 Mar 2013 at 4:24am

how are you getting the data into the report?

Are you grouping and you want the top 3 per group?
you can insert a running total that counts any field in the grup and resets at the group level then suppress the detail section based on this (e.g. #RT >3)
 
EDIT: Sorry Hilfy, was typing mine up when you posted Confused


Posted By: hilfy
Date Posted: 04 Mar 2013 at 4:53am
No problem Smile
 
-Dell


-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: abdulmoiz
Date Posted: 04 Mar 2013 at 10:16pm
yes, i am grouping data by patientID and then by Service Dates

and in each service date, i have CPT Codes and ICD Codes. My Requirement is to Limit the number of ICD Codes to 3. Now, my report has varying ICD Codes for Service Dates.

Thanks in advance.


Posted By: abdulmoiz
Date Posted: 04 Mar 2013 at 11:47pm
please find the detailed report output needed on this link:

https://docs.google.com/file/d/0BwFk9lyWmytlLTN0NkxycGlMaWs/edit?usp=sharing

Thanks



Print Page | Close Window