Symptom
How to summarize the columns of the Calculated Members in a Cross-tab 'vertically'
Environment
Crystal Reports 2008 (All Patch Levels)
Reproducing the Issue
- Create a Crystal Report against the Xtreme Sample database
- Insert a Cross-tab on the Report Header section (Insert->Cross-tab)
- Right click the Cross-tab and go to ‘Cross-tab Expert’
- Select ‘Orders.Order Date’ in the ‘Columns’
- Select ‘Customer.Country’ in the ‘Rows’
- Select ‘Customer.Last Year’s Sales’ in the ‘Summarized Fields’
- Click on OK
- Now, suppose you want to add a column which calculates the Last Year’s Sales difference between two particular dates in percentage
- Suppose you want to find difference between column 1 and column 2, then right click column 2 then select ‘Calculated Member’->’Insert Column’
- Now, a column would be inserted which would contain the difference between column 1 and column 2 shown as percentage
- Right click the newly added column and select ‘Calculated Member’->’Edit Calculation Formula’
- Type in the following formula:
- Save the formula and refresh the report
- Observe that the totals for the newly added column are calculated by dividing the Sub-total for Column 1 by the Sub-total for Column 2 We would like to calculate the Sub-total for the Calculated Member ‘vertically’
GridValueAt(CurrentRowIndex, CurrentColumnIndex-2, CurrentSummaryIndex) / GridValueAt(CurrentRowIndex, CurrentColumnIndex-1, CurrentSummaryIndex) * 100
Resolution
- Right click the Sub-total field for the Calculated-Member and click on the formula button of the ‘Display String’
- Type in the following formula:
- Note down the ‘CurrentColumnIndex’ of the column
- For now, let’s assume this value is 3
- Go back to the ‘Display String’ formula and type in the following formula:
- Save the formula and refresh the report
- Now, the Sub-total for the Calculated Member is calculated ‘vertically’
Totext(CurrentColumnIndex)
if CurrentColumnIndex = 3 then
totext(gridvalueat(0,3,0)+gridvalueat(1,3,0)+gridvalueat(2,3,0)+gridvalueat(3,3,0))
else totext(CurrentFieldValue)
Keywords
Cross-tab Calculated Member, summarize vertically , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To
Product
Crystal Reports 2008 V0 ; Crystal Reports 2008 V1