Search code examples
syntaxcrystal-reportsreportformula

how do i subtract two grandtotal fields in Crystal Reports


I'm using crystal reports and i have created two sum grandtotal fields. Now i want to do field 1 - field 2 in a X1 formula, but i can't call those fields into the formula. So I tried to use Sum({field1}) - 2 but that doesn't seem to get the grandtotal.

Is it possible to do a grandtotal in a sum like Sum({field1}.GrandTotal) ?


Solution

  • create a formula and write

    Sum({field1}-Sum({field2}
    

    and place it at the right most part that is after all columns.

    If this doesn't work then you can follow below process.


    Create a formula @Grandtotal1

    Sum({field1},{Group1}(if using group)
    

    create a formula @Grandtotal2

    Sum({field1},{Group2}(if using group)
    

    Now create another formula

    EvaluateAfter(@Grandtotal1);
    EvaluateAfter(@Grandtotal2)
    
    @Grandtotal1-@Grandtotal2