Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: displaying average on a chart Post Reply Post New Topic
Author Message
vlntine82
Newbie
Newbie


Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
Quote vlntine82 Replybullet Topic: displaying average on a chart
    Posted: 02 Jan 2007 at 6:56pm
Does anyone know how to display an average as a straight secondary line on a chart?

Edited by BrianBischof - 02 Jan 2007 at 9:48pm
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
vlntine82
Newbie
Newbie


Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
Quote vlntine82 Replybullet 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?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
vlntine82
Newbie
Newbie


Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
Quote vlntine82 Replybullet 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?
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet 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>
IP IP Logged
vlntine82
Newbie
Newbie


Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
Quote vlntine82 Replybullet 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.
IP IP Logged
vlntine82
Newbie
Newbie


Joined: 05 Dec 2006
Online Status: Offline
Posts: 18
Quote vlntine82 Replybullet 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?
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.012 seconds.