Conditional group SUM in Crystal Reports

2019-02-23 13:45发布

问题:

I've been doing some accounting reports and have been summing up my different currencies using a formula

IE

CanadianCommissionFormula

if {myData;1.CurrencyType} = "CDN" then
    {myData;1.Commission} 
else
    0


CanadianCommissionSum

SUM({@CanadianCommissionFormula})

Then I'd just display the CanadianCommissionSum at the bottom of the report and things were great.

I've just come across the requirement to do this, but grouped by Sales Rep. I tried using my previous formula, but this sums for the whole report. Is there an easy way to sum like this, based on which group it's in?

回答1:

You probably figured this out a year ago, but just in case, try this:

  1. Change your CanadianCommissionSum formula to

    SUM({@CanadianCommissionFormula},{SalesRep})

  2. Put this formula in your SalesRep's Group Footer section.

This should now display properly.



回答2:

Create a group based on the sales rep in the Crystal Report, and place the:

SUM({@CanadianCommissionFormula})

...in the footer of the group.



回答3:

I would assume that rexem's suggestion should work but since you said it gives you a total all of the sales reps you could change the sum to running total. Before doing this I'd double check that you have your field in the correct footer section though.

To do the running total, group by Sales Rep, and then set up your running total to evaluate on every record and reset on the change of the group. Then you can put this running total in the group footer and it will show subtotals.

Hope this helps.