Count Group Totals on a condition

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!
Erin LealeConsultant/ControllerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mlmccCommented:
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
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erin LealeConsultant/ControllerAuthor 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
0
mlmccCommented:
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
0
Erin LealeConsultant/ControllerAuthor 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!!!!!
0
Erin LealeConsultant/ControllerAuthor Commented:
As always - mlmcc is very helpful!  Thank you!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.