Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Averaging 3 fields and leave out the zero field Post Reply Post New Topic
Author Message
Rhanks
Newbie
Newbie
Avatar

Joined: 12 Feb 2008
Location: United States
Online Status: Offline
Posts: 4
Quote Rhanks Replybullet Topic: Averaging 3 fields and leave out the zero field
    Posted: 21 Feb 2008 at 1:37pm
I have 3 fields that represent the sales for the last 3 periods.  I want to find an average of the 3 fields.  But if one of the fields happens to be zero I want that left out of the calculation.  So it would be the average of 2 fields.  Is there a way to do this in Crystal Reports?  I am using XI.

Thanks
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 21 Feb 2008 at 6:17pm
Do you mean that you have many records and on each detail record you want to show the current avg sales for the past three records? This can be tricky b/c you have to keep a rotating list in memory of the what the last three were so that you can subtract the fourth one in the past. But if you just want to keep a running total and not include a value if it is zero, then I would do a manual running total that tracks the total sales so far as well as how many records have been counted. If a record is zero, then don't increase the counter for that record.

So which method are you trying to do for this report? The first or second one.
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
Rhanks
Newbie
Newbie
Avatar

Joined: 12 Feb 2008
Location: United States
Online Status: Offline
Posts: 4
Quote Rhanks Replybullet Posted: 22 Feb 2008 at 5:21am
What I have is a database that has already agregated the sales transactions and placed them in monthly bucket for the last 12 months.  So each month is a seperate field.  What I want to do is calculate the average monthly sales for the last 3 months or maybe the last 6 months for each customer.  But if one of those months happens to be zero I would like to drop it from the calculation.  This is to take into account a new customer coming during the interval I am look at and have some months that are zero.  This might skew the average downward.
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.016 seconds.