Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Resolved! Using "Where" in Formula Editor Post Reply Post New Topic
Author Message
bigbloo
Newbie
Newbie
Avatar

Joined: 09 Mar 2010
Location: Canada
Online Status: Offline
Posts: 19
Quote bigbloo Replybullet Topic: Resolved! Using "Where" in Formula Editor
     Posted: 04 Apr 2010 at 7:17pm
For the life of me I can't figure out how to write a conditional count query that the Formula Editor will accept.
 
I'm trying to write:
Count ({table1.fieldA})
Where ({table1.fieldB}) = R
 
 
Thank you for any help!


Edited by bigbloo - 14 Apr 2010 at 11:09am
Bigbloo
--------------------------------------------------
Information is power only when it's shared.
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 05 Apr 2010 at 4:54am
Short of creating seperate formulas with shared variables, I do not know of another way of doing it.
 
Example:  Formula 1 - Shared numbervar counter := 0;  'Initialize the variable
Formula 2 - Shared numbervar counter;
if {table1.fieldB] = "R" then counter := counter +1;  'Do the calculation
Formula  3 - Shared numbervar counter;
counter;   'Display the result.
 
I hope this helps.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 Apr 2010 at 9:41am
Here's another way to do it:
 
Formula:
 
If {table1.fieldb} = 'R' then 1 else 0
 
You can then use this formula in a summary that sums the formula at the group level.  If you need to do a distinct count, instead of '1 else 0' do '{table1.FieldA}' with no else statement.
 
-Dell
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 05 Apr 2010 at 10:12am
Duh, I knew that.  Must be Monday :-)
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 05 Apr 2010 at 10:15am
Wink I know that feeling!
IP IP Logged
bigbloo
Newbie
Newbie
Avatar

Joined: 09 Mar 2010
Location: Canada
Online Status: Offline
Posts: 19
Quote bigbloo Replybullet Posted: 05 Apr 2010 at 5:06pm
Thansk so much! I'll give it a try.
Bigbloo
--------------------------------------------------
Information is power only when it's shared.
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