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!

Group Summary: Count of Records Matching Criterion

Status
Not open for further replies.

DrFrankenstein

Programmer
Jul 7, 2010
2
CA
Hi,

I'm trying to do something with Crystal Reports that I thought would be simple (at least it was simple from my programmer mind), but it turns out to be not so obvious; at least to me.

I want to show the number of rows in a table matching some various criterion, grouped by a certain column; so, for example, if the table represented tasks, you'd get something like:
- Task priority (group by);
- Number of pending tasks;
- Number of pending tasks that are overdue;
- Number of tasks done within due date;
- Success percentage;
- Average execution time;
- Average execution time of tasks that were completed overdue;
etc. Well, you get the idea.

Now, I would know how to get the total number of tasks, or the average execution time of all tasks. However, I don't know how I'd have CR count rows in a group matching some criterion. Any advice on how I could proceed?
 
You either insert summaries at the group level or write a formula that includes the group condition, as in:

count({table.field},{table.groupfield})

-LB
 
Hi lbass,

I have no problem creating ordinary summary field, the problem I'm having is with creating summaries that, say, count only SOME records depending on criteria.
 
Then create a formula like this:

if {table.field} = "my criterion" then
{table.amt} //or 1 for a count

Then summarize the formula. If doing a count, use sum, not count, as the summary--since the count of a conditional formula will return the number of times it executes, not the count of how many records meet the criterion. There is a way of using a count/distinctcount on a conditional formula by using {@null} as the explicit default value, where {@null} is a formula that is opened and saved without entering anything.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top