Search code examples
crystal-reports

Adding two summaries in Crystal Reports


I have a report with two summaries in the report footer. They are both sums of two different formulas. I would like to add those two sums together into a grand total and then have the report also show what percent was sum A and what percent was sum B of the grand total.

I'm new to Crystal and can't figure this one out yet...

Thanks in advance!


Solution

  • You can create two grand total objects (in the same way as subtotal) on the report footer, then use a formula to do whatever logic is necessary:

    'Total: ' + cstr(Sum ({@CreditAmt}) + Sum ({@DebitAmt})) +
    ', @CreditAmt Contribution: ' + cstr((Sum ({@CreditAmt})/(Sum ({@CreditAmt}) + Sum ({@DebitAmt}))*100)) + 
    '%, @DebitAmt Contribution: ' + cstr((Sum ({@DebitAmt})/(Sum ({@CreditAmt}) + Sum ({@DebitAmt}))*100)) + 
    '%'
    

    In this example, @CreditAmt and @DebitAmt are both formulas, but this will work for fields as well. The grand total wizard has an option to show the total as a percentage of another field, but I've never been able to get it to work in 8.5 itself.