Count Group Totals on a condition

Erin Leale
Erin Leale used Ask the Experts™
on
I created a Cross Sell report - for every Fuel Customer we sell Lubes to - I need to count the customer in that Group and use the number in a formula for our score card.

In Crystal Reports - I have a field for Lube Sales  -I want to count any of the Lube sales in GF3 if the total is not 0.  I need to have the Count in GF2 to use in a formula.  I have tried several formulas and running totals and it is not working.  

Can you help?  I attached a screen shot of the report.

Thank you!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
I don't see the screen shot.

You will need 3 formulas

Put this formula in the Report Header and in Group 2 Header
WhilePrintingRecords;
Global NumberVar HasSalesCount;
HasSalesCount := 0;
''

Open in new window


In the Group 3 footer add a formula
WhilePrintingRecords;
Global NumberVar HasSalesCount;
If {Your Summary} > 0 then
     HasSalesCount := HasSalesCount  + 1;
''

Open in new window


IN the Group 2 footer add a formula
WhilePrintingRecords;
Global NumberVar HasSalesCount;
HasSalesCount 

Open in new window


mlmcc
Erin LealeConsultant/Controller

Author

Commented:
I added the formulas but for 1 record it is counting 3 - I'm not sure what I'm doing wrong.  I have attached the report saved with data.  

Thanks.
AR_LubeCrossSell_Custom.rpt
Cross-Sell-Report.jpg
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
3 is correct the way you have it defined.

Unsuppress Group footer 3.  You suppress the footer based on the qty shipped.  The filter on that formula filters out many more products than the lube formula. you'll see where the count increases.

You have customers with 0 shipped but the lube total > 0

Customers 0006924 and 0008114

mlmcc
Erin LealeConsultant/Controller

Author

Commented:
On the report - I need only Fuel Customers that had a delivery and I compare to anyone who bought Fuel and bought Lubes - So if the Fuel QTY is 0 then I don't include them in the Summary.  

I added this into the Condition and it is working.  

whileprintingrecords;

Global Numbervar LubeCount;
If Sum ({@Lube$}, {AR_InvoiceHistoryHeader.CustomerNo}) <> 0 and Sum ({@QtyShipped}, {AR_InvoiceHistoryHeader.CustomerNo}) <> 0 then LubeCount := LubeCount + 1;

Thank you for your help!!!!!
Erin LealeConsultant/Controller

Author

Commented:
As always - mlmcc is very helpful!  Thank you!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial