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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

To count number of records satisfying a particular condition

Status
Not open for further replies.

addygoyal

Programmer
Apr 24, 2003
21
ZA
Guys see if you can find something to get me out of this jam
i want to count number of records satisfying a particular condition.
i ve got this Number ID field {NumberID) and {SomeCodeField} and i want to count number of {NumberID)s only when {SomeCodeField}= 'CD'
An example about what i want to do

{SomeCodeField} {NumberID)
AB 1
2

CD 3
4
5

EF 6
7
8
9
i want to count {NumberID)
when {SomeCodeField} = 'EF'
here this will be equal to 4

Hopin you ppl gonna find something
 
In Crystal 8.5, you can create Running Totals which count using a formual. This formula can be as complex as you like, and it may also test the results of one or more formula fields.

Madawc Williams
East Anglia, Great Britain
 
thank you Madawc ,

using total works upto counting now i want to display the maximumm of this count on the page header section. Is there some way to find this maximum count number

Aditya Goyal
Bombay,India
 
Running totals are calculated by Crystal at the same time as the section is printed, so that you can only use their value in sections that are printed afterwards.

Summary totals are available before printing, but they only do simple sums, counts, maxima or minima, not conditional counts.

As far as I know, there is no way round this limit, assuming that this is what you're after. You could post it as a new thread, in the hope that there is some method.

Madawc Williams
East Anglia, Great Britain
 
Your example states that you only want to count the ID field when a code field equals a specific value, therefore, there would be only one count which automatically would equal the maximum count. Are you actually selecting several code fields and you want the maximum of the set of separate counts?

Is there a reason you are not using the record selection statement to eliminate code types that you don't want counted?

A little more information might lead to some helpful suggestions.

-LB
 
guys thanks for your responses taking some inputs from your responses and using some way arounds i ve finally found the fix.
It required a view to be created in the database where i have made Count of Number IDs per code as one of the fields and then created a formula field where i pick this count
So the view was some thing like this

{SomeCodeField} Count Of{NumberID)
AB 2
CD 3
EF 4

i used a formula wherby i selected count for the particular code

Thank you all
 
For future information, to do this in Crystal Reports :

Create Group on {SomeCodeField}, right click on {SomeCodeField} > insert > summary > count, evaluate at group level.
ensure {SomeCodeField} in the group footer, suppress Group Header and Detail.


Reebo
Scotland (Sunny with a Smile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top