School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,418 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,562 people online right now. Registration is fast and FREE... Join Now!




Calculating the rolling average in crystal reports using the previous

 

Calculating the rolling average in crystal reports using the previous

Armish87

17 Jun, 2009 - 01:39 AM
Post #1

New D.I.C Head
*

Joined: 27 May, 2009
Posts: 3

I'm trying to calculate the rolling average in a crystal report. I have got 4 weeks in a month, and I have calculated the average for each week so long. Now I want to calculate a rolling average.
eg:
For week1: rolling average = (week1Average)/1
For week2: rolling average = (week1Average + week2Average)/2
For week3: rolling average = (week1Average + week2Average + week3Average)/3
etc.

The problem with the code below is that, it is not looping through,therefore the rolling average for each week is the same as its average value wich is not correct.

CODE

Dim i, weekNum as number
Dim tot as double
  
    weekNum =Distinctcount({ItemRating.WeekNo})
    tot = 0
    for i = 1 To weekNum
       tot = tot + Average ({ItemRating.RatingScaleNo}, {ItemRating.WeekNo})
       formula = tot / i
     next i


This post has been edited by Armish87: 17 Jun, 2009 - 11:14 PM

User is offlineProfile CardPM
+Quote Post


bsaunders

RE: Calculating The Rolling Average In Crystal Reports Using The Previous

18 Jun, 2009 - 01:56 PM
Post #2

D.I.C Addict
****

Joined: 18 Jan, 2009
Posts: 554



Thanked: 42 times
My Contributions
What is the purpose of the formula variable?
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/7/09 11:36PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month