Print Page | Close Window

Calculated Member in Cross-Tab

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=18270
Printed Date: 18 May 2024 at 6:57pm


Topic: Calculated Member in Cross-Tab
Posted By: upndown4par
Subject: Calculated Member in Cross-Tab
Date Posted: 14 Dec 2012 at 8:08am
In a subreport, I have a chart and a cross-tab using the same query.  The query retrieves a rolling 12 months worth of data, which the chart shows.  The cross-tab only needs to show the last 2 months of data.  To accomplish that, I created 2 summarized fields:  one that shows the data for each month and one that sets the value to 0 for all but the last 2 months. 

The chart is showing the data as intended.  For the cross-tab, I want to add a Calculated Member after the 2nd month that shows the percentage variance between those 2 months.

I am able to create the Calculated Member using the Difference formula and the formula it uses is:
GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("201209"), CurrentSummaryIndex) - GridValueAt(CurrentRowIndex, GetColumnPathIndexOf("201208"), CurrentSummaryIndex)

Because the Calculated Member column was inserted between those 2 columns, I created a column after the last column and copied the formula from the Calculated Member into there and then removed the Calculated Member.

In this case, the report was run for September 2012 so it will only show 201209 and 201208.

If the report was being run for October, however, the column headers would be "201209" and "201210", which would mean that the formula would be incorrect.

Instead of using the column name of "201209",, I tried using this:
GridValueAt(CurrentRowIndex, CurrentColumnIndex -1, CurrentSummaryIndex).  Unfortunately, it's causing an out of range error.

Is there a simpler way to get the correct formula?  Preferably, one that works!  Tongue

Any ideas and/or suggestions would be greatly appreciated.

I am using Crystal Reports 2008, version 12.1.0.892.

Thanks in advance.

Ron



Print Page | Close Window