SAP Knowledge Base Article - Public

1669306 - How to show the difference between two column values in a cross-tab in Crystal Reports?

Symptom

  • How to calculate the difference between 2 columns?
  • How to show the difference between two column values in a cross-tab in Crystal Reports?

Environment

  • SAP Crystal Reports 2016
  • SAP Crystal Reports 2020

Resolution

  • To calculate the difference between columns on a cross-tab, use the Calculated Member functionality:
     
    1. On the cross-tab, right click on the column header showing the field value, and select: Calculated Member - Insert Column
    2. A column with a blank header and zero values will be added to the cross-tab.
    3. Right-click on the blank column header and select: Calculated Member - Edit Header Formula 
    4. Then type "Difference" in the editor.
    5. Now, the blank column header displays the text 'Difference'.
    6. Right-click on one of the zero values in this column, and select: Calculated Member - Edit Calculation Formula
    7. Type a formula to calculate the difference in editor, like:
        
      Gridvalueat(currentrowindex,currentcolumnindex-1,currentsummaryindex) - Gridvalueat(currentrowindex,currentcolumnindex-2,currentsummaryindex)
            
    8. The cross-tab now display the difference between the two columns.
             
         
  • For more information on the functions used in the formula to calculate values in a cross-tab, see the Crystal Reports help.

Keywords

CR, Difference between two fields, difference, cross tab, difference between two fields in cross tab, crystal reports , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 2016 ; SAP Crystal Reports 2020