Print Page | Close Window

displaying average on a chart

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
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=84
Printed Date: 05 May 2024 at 1:48am


Topic: displaying average on a chart
Posted By: vlntine82
Subject: displaying average on a chart
Date Posted: 02 Jan 2007 at 6:56pm
Does anyone know how to display an average as a straight secondary line on a chart?



Replies:
Posted By: BrianBischof
Date Posted: 02 Jan 2007 at 9:41pm
To plot the average on the chart, I created a formula which calculates the average as a running total. The I plotted that formula on the same chart that has the original value you are charting. Here is a sample of the formula:

Global NumberVar  TotalOrder;
Global NumberVar OrderCount;
NumberVar AverageOrder;

OrderCount := OrderCount + 1;
TotalOrder := TotalOrder + CDbl({Orders.Order Amount});
AverageOrder := TotalOrder/OrderCount;



-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: vlntine82
Date Posted: 03 Jan 2007 at 7:23am
How do you plot a formula?  I know how to create the formula, but what do I do to get it to plot on the chart?


Posted By: BrianBischof
Date Posted: 03 Jan 2007 at 9:19am
Same way you would plot any data point. When you have the Chart Expert open, it is in the Available Fields list along with all the other fields in the data source. Drag and drop it next to the other data point you want to chart.

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: vlntine82
Date Posted: 03 Jan 2007 at 9:25am
When I try to create the formula, I am getting the error "the formula result must be a boolean".  How do I make it a boolean if I am wanting the average returned?


Posted By: BrianBischof
Date Posted: 03 Jan 2007 at 9:29am
Hmmm, don't know why you would be getting that. Something must be off for it to be expecting Boolean. Are you using Crystal Syntax and not Basic Syntax? 

-------------
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>


Posted By: vlntine82
Date Posted: 03 Jan 2007 at 9:42am
It is set to Crystal Syntax.  Also, there is an average function (Average ({graph_data.tmpData}))  that I can use, but I still get the same result.


Posted By: vlntine82
Date Posted: 03 Jan 2007 at 1:03pm
I was able to get the formula to work.  Now I need to make the title of the graph set to a parameter.  Is this possible?



Print Page | Close Window