Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Performing a count on a formula in a column Post Reply Post New Topic
Author Message
Tonza
Newbie
Newbie
Avatar

Joined: 07 Jul 2009
Location: Australia
Online Status: Offline
Posts: 2
Quote Tonza Replybullet Topic: Performing a count on a formula in a column
     Posted: 07 Jul 2009 at 8:47pm

I have an issue with performing a count on columns that are already formulas.  What I mean by that is there are a number of hours for the field I am calculating.  E.g, Column 1 is a formula that returns a value of Cat1 if the hours are Less than 2.  Column 2 returns a value of Cat2 if the hours are betweeen 2 and 4, etc.  These are set up as If..Then statements.

Here is the report I have already created...
 
Hours Column     Column 1       Column 2       Column 3      Column 4
         2                    Cat1           
         6                                                                Cat3
         3                                           Cat2
         4                                           Cat2
         9                                                                                    Cat4
         1                    Cat1
         7                                                               Cat3
         8                                                               Cat3
         5                                                               Cat3
 
This is what I would like to achieve in the report:
 
Totals for Cat1 = 2
Totals for Cat2 = 2
Totals for Cat3 = 4
Totals for Cat4 = 1
 
Can anyone help?


Edited by Tonza - 07 Jul 2009 at 8:48pm
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 08 Jul 2009 at 4:50am
You can use running totals to conditionally count:
Column 1 example:
Right click on Running Total and select New.
RT Name as "Column1 Total"
Field to Summarize=table.hours field
Type of SUmmary=Count
Evaulate set to "Use a Formula". Add the formula of :
{table.HoursField} in 1 to 2
Reset as Never.
Repeat for next option "Column2 Total" but change the formula to
{table.HoursField} in 3 to 4
Repeat for each option you need counted
 
or you can make more formulas that that use 1 or 0 conditionally and sum those...Example...
Create a formula field as "Column1 Count":
if {table.HoursField} in 1 to 2 then 1 else 0.
Sum this formula.
Repeat for each option.


Edited by DBlank - 08 Jul 2009 at 6:18am
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 08 Jul 2009 at 6:06am
Add a variable to your existing formulas that increment everytime that they display a value.  At the footer, create formulas to display your counters.
 
Just expand on what is already in place, since you know that the logic is correct.
IP IP Logged
Tonza
Newbie
Newbie
Avatar

Joined: 07 Jul 2009
Location: Australia
Online Status: Offline
Posts: 2
Quote Tonza Replybullet Posted: 08 Jul 2009 at 7:45pm
Thankyou very much DBlank and lockwelle for your replies.  I have actually gone with the adding new formulae to the current groups that I have created and placed it in the GF area and this has worked like a charm.  I used DBlank's idea as I am not yet as conversed with variables, but I guess I will eventually have to use them if the reports need to be more involved.
 
IP IP Logged
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