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

Getting Conditional Counts

Status
Not open for further replies.

rasprer

Programmer
Feb 12, 2004
102
US
Fellow Professionals,

I am using Crystal v.11. I've lost all knowledge with Crystal and now I'm just getting back to it again due to a new job.

Here's my question...
I need to do display multiple counts on my report dependent upon certain conditions. ie.

my data is as follows in the detail section and grouped by name:

Name Grade Improve
TOM A YES
TOM A YES
TOM B NO
JON C YES
JON B NO
JON A NO

The counts I want to display are:

TOM has grade of A = 2
TOM has Grade of B = 1
TOM has GRADE of C = 0
TOM has Grade of D = 0
TOM has grade of E = 0

JON has grade of A = 1
JON has Grade of B = 1
JON has GRADE of C = 1
JON has Grade of D = 0
JON has grade of E = 0

You assistance is greatly appreciated
 
Try running totals - they can include formulae.

TO remind you of the basics, since you say you've forgotten. There are several ways to find totals: running totals, summary totals, grand totals and variables. Right-click on a field and choose Insert to get a choice of Running Total, Summary and Grand Total. Or else use the Field Explorer, the icon that is a grid-like box.

It is also possible to get get totals using a Formula Field, which can contain a Variable or a Directly Calculated Total.

Running totals allow you to do clever things with grouping and formulas. They also accumulate for each line, hence the name. The disadvantage is that they are working out at the same time as the Crystal report formats the line. You cannot test for their values until after the details have been printed. You can show them in the group footer but not the group header, where they will be zero if you are resetting them for each group.

Summary totals are cruder, but are based directly on the data. This means that they can be shown in the header. They can also be used to sort groups, or to suppress them. Suppress a group if it has less than three members, say.

Grand totals are much like summary totals, but for the whole report rather than groups. Note that summary totals include an option to have a grand total calculated on the same basis.

Variables are user-defined fields. One useful variant are shared variables to pass data from a subreport back to the main report. You can also use variables to show page totals. For normal counting I find running totals or summary totals much easier.

Directly Calculated Totals within a Formula Field can be coded directly, with commands like Sum ({ADV01.Advance}, {ADV01.AccType}). The same result can be achieved by picking up an existing Variable, and will keep the code even if the Variable itself is later deleted. Formula fields can also include Running Totals and other Formula Fields, with some limits depending on when the values are calculated.

To get yourself familiar with the idea, try doing a test report with a summary total and a running total for the same field, placed on the detail line. You'll find that the running total increases as each line is printed, whereas the summary total has the final value all along.

This is based on Crystal 10; you may have extras in 11.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Thanks Madwac for the info. Very much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top