Print Page | Close Window

A Count which excludes supressed records

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=7201
Printed Date: 28 Apr 2024 at 2:33pm


Topic: A Count which excludes supressed records
Posted By: 602729729
Subject: A Count which excludes supressed records
Date Posted: 30 Jul 2009 at 2:08am

Hello, i hope you experts out there can help me with the following.

I am trying to provide a count for a group which doesn't include the supressed records. So let me expand on this by providing an example:
 
Name         Age              Active        Colour
Smith         23                 0                blue
Johnson     56                 1                blue
Mclarren    23                  1                red
Khan          67                 1                blue
 
So, using the 'Section Expert' dialogue i have supressed those records which are inactive and then provided a count. The count is based on the group 'Colour'. There are two groups, blue and red. I seem to be getting 3 as a count for the blue when i am only expecting 2.
 
How can i get my count to only consider those records which are not supressed. Hope you can help!
 
Thanks in advance!
 
Imran.



Replies:
Posted By: DBlank
Date Posted: 30 Jul 2009 at 4:40am
You can use a Running Total.
Add a formula as the condition to include ... {table.Active}=1
If you have your data grouped on color field then reset it on that group and place the RT field on your footer.
If it is not grouped then you will have to make 2 running totals (1 per color) and add that condition to your formula...{table.Active}=1 and {table.color}="blue"
Reset as Never and place on report footer.


Posted By: DBlank
Date Posted: 30 Jul 2009 at 6:29am
Per your request, here is a little more explanation of how to create and use a Running Total for this process.
Right click on the Running Total Fields in Field Explorer and select New.
Give it a Name that works for you to understand..I will use "Active Count"
The field to summarize = table.color
Type of Summary = COUNT
In teh Evaluate hit the toggle button next to "Use a formula". Thia activates teh Formula button. Click on it and add your formula here. This is a formula that tells it which items to include int he count. Anytime where the formula evaluates to TRUE will be included in the count so your formula  should be .... {table.ActiveField}=1
Now in the Reset click on  On change of Group (this is only an option if you have a group set up in the report). Add the leve you grouped on the COLOUR field.
Now if you place this Running Total field (drag and drop from the Field Explorer) onto the Group Footer it will count only rows in that group where the active field =1.
If you did ot group on the color field then you want to make to RT fields that include another condition for counting.
I would make one called BLUE.
It is the same process but in the formula in the Evaluate section add the extra condition to look at the response in the color field...
{table.ActiveField}=1 and {table.color}="blue"
For Reset you want ot look ata ll of the records so you set it as NEVER.
Place it on the Report Footer.
Create a another one as RED and just cnage the formula to
{table.ActiveField}=1 and {table.color}="red"
 
FYI -Running Totals only work on Detail sections, or footers. Tehy must be placed in report section that is below the printed records that is evaluating (or on the detial section to show a change per row).
 
Does this answer your questions? If not please feel free to post more detailed questions. These posts are good references for others in the future. Thumbs%20Up


Posted By: 602729729
Date Posted: 30 Jul 2009 at 6:45am

Thank you soo much for responding to my questions. Your solution works perfectly fine and after much tweaking and making use of Running Totals which i didn before, my formula has not evolved into this:

WhilePrintingRecords;
   numbervar total;
if mailto:%7b@siteCode - {@siteCode } <> previous ( mailto:%7b@siteCode - {@siteCode }) then total := 0;
   if GroupName ( mailto:%7b@siteCode - {@siteCode }) = GroupName ( mailto:%7b@siteCode - {@siteCode }) then total := total + 1;
 
Thanks,
 
Imran!
 
Wink
 



Print Page | Close Window