Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: A Count which excludes supressed records Post Reply Post New Topic
Author Message
602729729
Newbie
Newbie
Avatar

Joined: 30 Jul 2009
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote 602729729 Replybullet Topic: A Count which excludes supressed records
    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.


Edited by 602729729 - 30 Jul 2009 at 2:17am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet 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
IP IP Logged
602729729
Newbie
Newbie
Avatar

Joined: 30 Jul 2009
Location: United Kingdom
Online Status: Offline
Posts: 2
Quote 602729729 Replybullet 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 {@siteCode} <> previous ({@siteCode}) then total := 0;
   if GroupName ({@siteCode}) = GroupName ({@siteCode}) then total := total + 1;
 
Thanks,
 
Imran!
 
Wink
 
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.031 seconds.