### How i can create Calculated Columns Dynamically in Crosstab report CR 2013

Hello All,

I have prepared crosstab report in Crystal Report 2013 as shown below and get year difference using calculate columns fields. But year difference not appeared when i change the input parameter and select other year. I need help to create calculated columns dynamically.

Report Criteria

Report Output

rptoutp.jpg

I used to below code in calculated columns to show year difference

Difference b/w 15 & 16

if GetColumnPathIndexOf({?Year}-3)= - 1 then 0 else if {?Year}>0 then -(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-3), CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-2), CurrentSummaryIndex))

Difference b/w 15 & 17

if GetColumnPathIndexOf({?Year}-3)= - 1 then 0 else if {?Year}>0 then -(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-3), CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-1), CurrentSummaryIndex))

Difference b/w 15 & 18

if GetColumnPathIndexOf({?Year}-3)= - 1 then 0 else if {?Year}>0 then -(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-3), CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}), CurrentSummaryIndex))

Difference b/w 16 & 17

if GetColumnPathIndexOf({?Year}-2)= - 1 then 0 else if {?Year}>0 then -(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-2), CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-1), CurrentSummaryIndex))

Difference b/w 16 & 18

if GetColumnPathIndexOf({?Year}-2)= - 1 then 0 else if {?Year}>0 then -(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-2), CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}), CurrentSummaryIndex))

Difference b/w 17 & 18

if GetColumnPathIndexOf({?Year}-1)= - 1 then 0 else if {?Year}>0 then -(GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}-1), CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, GetColumnPathIndexOf({?Year}), CurrentSummaryIndex))

Many thanks for any hint, much appreciated.

Best Regards,

rptcriteria.jpg (17.1 kB)
rptoutp.jpg (94.5 kB)
10|10000 characters needed characters exceeded
• Hi Abhilash,

Thank you for your help. After your help, year is appearing dynamically but I am getting another issue while page navigation. Screen shot is as under:

Many thanks for any hint, much appreciated.

Best Regards,

cr2013.jpg (42.4 kB)

• Mar 05, 2018 at 07:55 AM

Hi Anwar,

Right-click the Calculated Column's header cell > Select Calculated Member > Edit Insertion Formula > Use this code:

GetColumnGroupIndexOf(CurrentColumnIndex) = 0

-Abhilash