?
Solved

How do I count the first record in a group and show the result at the end of the report?

Posted on 2008-11-12
8
Medium Priority
?
222 Views
Last Modified: 2013-11-15
I am creating a report in employee # order that groups on employee#.  There may be varying number of records per employee# with amounts to be totaled on the report.  I want a distinct count of the number of employees shown on the report.  I have tried the running total, with change on group and no reset, but I still get the count of all records instead of count of employees.  
0
Comment
Question by:MsLED
  • 4
  • 4
8 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1500 total points
ID: 22952576
Try 2 ideas

First
Right click the Employee# field
Click INSERT --> SUMMARY
Select DISTINCT COUNT as the type of summary
Put it in the report footer.

If that doesn't work use a manual method
In the report header
WhilePrintingRecords;
Global NumberVar EmployeeCount := 0;
''

In the group header
WhilePrintingRecords;
Global NumberVar EmployeeCount;
EmployeeCount := EmployeeCount + 1;
''

In the report footer
WhilePrintingRecords;
Global NumberVar EmployeeCount;
EmployeeCount

mlmcc
0
 

Author Comment

by:MsLED
ID: 22955635
Thank you for your response.  

The first solution did not give me the expected results.
I tried the second solution and am getting a count higher than I expect.  As long as I have the 'WhilePrintingRecords', does that handle record selection that I have in an if clause?
This is code I have included in the Group Header:

WhilePrintingRecords;
Global NumberVar EmployeeCount;

if {F06146.YNPDBA}in 1 to 49 or
 {F06146.YNPDBA} in 60 to 62 or
 {F06146.YNPDBA} in 65 to 67 or
 {F06146.YNPDBA}in 802 to 803 then
 EmployeeCount:= EmployeeCount + 1;
 

0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22956753
The WhilePrintingRecords just tells Crystal when to run the formula.  In this case during the PrintingRecords pass (final pass) of building the report.  It is the only pass where variable values are maintain from record to record.

DistinctCount will count 1 for each it finds.  In your case you need to filter further.

What groups do you have?

mlmcc
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MsLED
ID: 22960921
The group is on employee number but there may be varying number of records for each employee and some employees excluded based on the parameters passed.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22962645
When you say excluded, the filtering is done in the record selection rather than in the report?
If it being filtered then the counts should be correct.

If you are suppressing then you need to apply that test to the formulas also

mlmcc
0
 

Author Comment

by:MsLED
ID: 22963232
Filtering is being done in record selection section.  The code I previously included is used in the amount totals as each record is read.  It doesn't seem that it needs to be included to determine whether an employee is selected.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 22963401
What is the group field?  If it isn't employee number then you will still get duplicates.

Is you number higher or lower than expected?

mlmcc
0
 

Author Closing Comment

by:MsLED
ID: 31516097
Thank you for your help.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi, In my previous Article  (http://www.experts-exchange.com/Database/Reporting/A_15199-Introduction-to-Microstrategy.html)I discussed some basic understanding of Microstrategy that how we can get in Intro of Microstrategy (MSTR). Now it's tim…
How to increase the row limit in Jasper Server.
Screencast - Getting to Know the Pipeline
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question