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

Summing Distinct Counts

Status
Not open for further replies.
Mar 20, 2009
102
US
I have the below fields:

HR Solutions 498
HR Solutions RTI 1,020

These are computed using the distinct count function. How can I add those 2 together to get the correct answer? I am doing a distinct count and placing it in the group footer and I am coming back with 1,513 as opposed to 1,518 because there are 5 emps that appear in both list and they should.

Any help is greatly appreciated!

Thanks
 
Create a formula and in the formula editor pick your two distinct counts from the report fields and add them together.

should look something like this
DistinctCount ({Command.Agency_Tie}, {@groupfield})+DistinctCount ({Command.Agency_Tie}, {@groupfield})

add that to the report or group footer you want the calculation in

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
These counts are part of the same grouping? This is how the reports looks in the hierachy:

HR Solutions
HR Solutions 498
HR Solutions RTI 1,020
(These are BU groupings and I added a distinct count based on empid to each grouping)

When using the suggestion above, the number is too high:

DistinctCount ({Command.employeeid}, {Command.BU})+DistinctCount ({Command.employeeid}, {Command.BU})




 
I have to learn to ask more questions before I respond.

Could you create a Distinct count running total that only evaluates (use the formula option) on the groups that meet your criteria and never resets?

_____________________________________
Crystal Reports XI Developer Version
Intersystems Cache 5.X ODBC connection

 
Tried and that doesn't work either.. Thanks for your help!!
 
If you want to count people in both groups, then you can use a variable like this:

//{@accum} to be placed in the BU group section:

whileprintingrecords;
numbervar sumgrp := sumgrp + distinctcount({Command.employeeid}, {Command.BU});

Then in the report footer, use this formula:

whileprintingrecords;
numbervar sumgrp;

-LB
 
Thanks lbass, that works for the first EIN, but when I go to the next BU, it continues to add the totals. I need it to be per EIN:

HR Solutions
HR Solutions 498
HR Solutions RTI 1,020
1,518 (this shows correctly)
HCSS East
HTR 6
National 61
NY Temp 89
(this shows the combined total including the amount above)..

Need them to be separate

Thanks a million!!

 
If you have an outer group, you need a reset formula, to be placed in the EIN group header:

whileprintingrecords;
numbervar sumgrp;
if not inrepeatedgroupheader then
sumgrp := 0;

-LB
 
Thanks! I have the 2 formulas in place, and now I am getting the individual totals, but not the overall total as before. Please advise as to how I can accomplish both totals. I apologize, but I "Junior" at doing these formulas.

Thanks!
 
Nevermind~ got it! Thanks for all of your help with this issue.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top