Symptom
- The methods used to create a manual running total in a report do not work in a cross-tab.
- How to create a manual running total in a cross-tab, on a report, in Crystal Reports?
Environment
- SAP Crystal Reports 2020
- SAP Crystal Reports 2025
Resolution
- To create a manual running total in a cross-tab use the Display String option of a summary field on a cross-tab.
- Below are general steps on how to create manual running total on a cross-tab for the row, as well as for a column.
- To create a manual running total for a row in a cross-tab:
-
- In Crystal Reports, create a report based on any data source.
- Insert a cross-tab, by selecting 'Insert - Cross-Tab'.
- In the 'Cross-Tab Expert', add a database fields for the column, one for the rows, and one for the summary.
- Add the same field again you want to summarized. The second instance of this field will be used to display the manual running total.
- Click the 'Customize Style' tab and under 'Summarized Field', select 'Horizontal'.
- Click the 'OK' button to close the 'Cross-Tab Expert' dialog box.
- Place the cross-tab in the Report Header section.
- On the cross-tab, right click the second summary field and click 'Format Field'.
- On the 'Common' tab, click the 'X+2' button next to 'Display Text'.
- Enter a formula in the 'Format Formula Editor' to calculate the running total and display the value. The formula will be like:
global numbervar RowNumber;
global numbervar RunningTotal;
global numbervar array SummaryValues;
global datetimevar ColumnValue;
If GridRowColumnValue ("<Row Database Field Alias Name>") <> ColumnValue then RowNumber:=0;
ColumnValue := GridRowColumnValue ("<Database Field Name>");
RowNumber := RowNumber + 1;
RunningTotal := 0;
Redim Preserve SummaryValues[DistinctCount(<Database Field Name>)];
RunningTotal := SummaryValues[RowNumber] + ToNumber(CurrentFieldValue);
SummaryValues[RowNumber] := RunningTotal;
ToText(SummaryValues[RowNumber],0)
NOTE:
The Row Database Field Alias Name is the alias assigned to the database field used in the cross-tab.
The alias for a field can be found in the 'Functions' box of the 'Format Formula Editor' dialog box under 'Formatting Functions' > 'Row or Column Names'.
- Click the 'Save and close' button to close the 'Format Formula Editor' dialog box.
- Click the 'OK' button to close the 'Format Editor' dialog box.
- Refresh the report.
- A row manual running total will now be displayed in the cross-tab.
- To create a manual running total for a column in a cross-tab:
-
- In Crystal Reports, create a report based on any data source.
- Insert a cross-tab, by selecting 'Insert - Cross-Tab'.
- In the 'Cross-Tab Expert', add a database fields for the column, one for the rows, and one for the summary.
- Add the same field again you want to summarized. The second instance of this field will be used to display the manual running total.
- Click the 'Customize Style' tab and under 'Summarized Field', select 'Horizontal'.
- Click the 'OK' button to close the 'Cross-Tab Expert' dialog box.
- Place the cross-tab in the Report Header section.
- On the cross-tab, right click the second summary field and click 'Format Field'.
- On the 'Common' tab, click the 'X+2' button next to 'Display Text'.
- Enter a formula in the 'Format Formula Editor' to calculate the running total and display the value. The formula will be like:
global currencyvar rt;
global datetimevar column;
if gridrowcolumnvalue("<Column Database Field Alias Name>") <> column then rt:= 0;
rt := rt + currentfieldvalue;
column:= gridrowcolumnvalue("<Column Database Field Name>");
totext(rt)
NOTE:
The Column Database Field Alias Name is the alias assigned to the database field used in the cross-tab.
The alias for a field can be found in the 'Functions' box of the 'Format Formula Editor' dialog box under 'Formatting Functions' > 'Row or Column Names'.
- Click the 'Save and close' button to close the 'Format Formula Editor' dialog box.
- Click the 'OK' button to close the 'Format Editor' dialog box.
- Refresh the report.
- A row manual running total will now be displayed in the cross-tab.
Keywords
cr, cross-tab crosstab manual running total , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To
Product
SAP Crystal Reports 2020 ; SAP Crystal Reports 2025
SAP Knowledge Base Article - Public