Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: How to Count fields that are non-zero (CountIf?) Post Reply Post New Topic
Author Message
ekotek
Newbie
Newbie
Avatar

Joined: 02 Nov 2009
Location: United States
Online Status: Offline
Posts: 4
Quote ekotek Replybullet Topic: How to Count fields that are non-zero (CountIf?)
    Posted: 02 Nov 2009 at 8:58am
Hey everyone,
Total newbie with Crystal Reports Formulas...
Hoping to get help with this..
 
Basically, I have a formula that looks like this:
 
Average ({tblEmployee_Team_Available_Hours.TotalProjectHours}) - Sum ({tblProject_Employee_TimeEstimates.Hours})
 / Count ({tblProject_Employee_TimeEstimates.Hours})
 
The only problem is that some of the records in {tblProject_Employee_TimeEstimates.Hours} are zeroes...I'd like to exclude those records...couldn't find anything similar to Excel's CountIF....
Please help....
IP IP Logged
Countrystyle
Newbie
Newbie


Joined: 25 Jan 2008
Online Status: Offline
Posts: 5
Quote Countrystyle Replybullet Posted: 02 Nov 2009 at 1:20pm
Not sure if this is exactly what you are looking for but ...
 
Create a formula:
if  {tblProject_Employee_TimeEstimates.Hours} = 0 then "error" else
Average ({tblEmployee_Team_Available_Hours.TotalProjectHours}) - Sum ({tblProject_Employee_TimeEstimates.Hours})
 / Count ({tblProject_Employee_TimeEstimates.Hours})
 
and then use the 'Select Expert' to exclude all 'Error's.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 02 Nov 2009 at 2:51pm
There are 3 basic ways to do this if you do not want to exlude data rows.
1.variable formula to coniditionally count (lots of examples on this site)
or
2. a Running Total (RT) to coniditionally count
RT Name: NonZeroCount
Field to summarize={tblProject_Employee_TimeEstimates.Hours}
Type of Summary=Count
Evaluate=Use a formula...
{tblProject_Employee_TimeEstimates.Hours} <> 0
reset=Never
 
(this must be used in the report footer since it is evaluating all rows).
 
3. if you have no duplicate records in the data set just use a formula to make a row =1 or 0 and then Sum that formula field
Name=RowCount
if {tblProject_Employee_TimeEstimates.Hours} = 0 then 0 else 1


Edited by DBlank - 02 Nov 2009 at 2:54pm
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.030 seconds.