Avatar of csenor
csenor
 asked on

Totals for a Special group deduction in Crystal Reports

I am having problems with a total in Crystal Reports. I have a report that has 2 Groups. I need to make a specific deduction for each group that is not related to the detail records. I have created that special deduction with the following formula:

WhilePrintingRecords;
if {Database.ItemClass} = "Group A" then 2000 else
if {Database.ItemClass} = "Group B" then 3000 else 0  

That works fine until I go to get a Grand Total of Groups A & B for the special deduction field. There is not a problem with other fields because they exist in the detail, but with this special field the amounts exist at the Group Level only.

I would appreciate any help. I certainly think that Crystal Reports would be able to keep a total for these "special' amounts, but I can not find the solution in my manuals.  

Here is the format of my report:


                  Item Name      Qty            Expense            Special Deduction
                                    
      detail            Item A1            10            3,000      
      detail            Item A2            10            3,000
      detail            Item A3            10            3,000      
Group       Group A Totals            30            9,000            2,000
                                    
      detail            Item B1            20            6,000      
      detail            Item B2            20            6,000      
Group      Group B Totals                    40            12,000            3,000
Crystal Reports

Avatar of undefined
Last Comment
csenor

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Mike McCracken

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
James0628

If you want to get a total of the special deduction formula, but only include it once per group, you could use a running total.

 Put your special deduction formula in the detail section, right-click and select Insert > Running Total.  Under Evaluate select "On change of group" and select your group.  Then the value from that formula will only be added once for each group.  After you create the running total, you can remove that formula from the detail section.

 James
csenor

ASKER
This advice me in the right direction. I had a problem with the variables keeping a running total, but I learned how to reset the variable after the group printed. Thanks for the advice----
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23