Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Count function when there is one condition

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hi. I'm trying to use the count function to give me a count when field x = 1 (literally), i.e. a count of the number of times the value 1 exists in field x.

Field x is text with only two values, 1 or 2.

Any help is appreciated.

Thanks!

Sincerely,
rock
 
Use a Running Total and in the evaluate use a formula area place something like:

{MyTable.MyField} = 1

You can also create a formula which will accomplish the same thing with something like this:

@columnToSumFormula
whileprintingrecords;
if {MyTable.MyField} = 1 then
1
else
0

Now you can place this in the detail and use the conventional Insert->Summary and use SUM.

I prefer Running Totals because it's less code to maintain and more intuitive for most.

-k kai@informeddatadecisions.com
 
Excellent! I used your 1st solution. It worked fine.

I'm really new to programming and haven't worked with Crystal syntax much. I didn't understand how to use running totals I guess and was trying to build a formula, which I couldn't get quite right.

Thanks again!

Sincerely,
rock
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top