Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Calculation conditional average Post Reply Post New Topic
Author Message
Afi83
Newbie
Newbie


Joined: 08 Oct 2009
Online Status: Offline
Posts: 7
Quote Afi83 Replybullet Topic: Calculation conditional average
    Posted: 04 Nov 2009 at 10:45pm
Hi there
I have a database in access i use ttx(data definition file) to pass my recordset from my VB6 app to crystal 8.5. I do it with no problem but my problem is here.
I have a grades table that for each student save credits. I have a predefined form that must be filled with each student average. i don't know how can i put in my reports only the average of each student without their fully credits.

Can i extract the average from all the grades and put it on my form.
I also need to add another grade from the grade with specific code besides to my average and calculate new average from these to values.
all in all i want to calculate the final average between this two values;
formula=avg(gradesaverage and (new value if coursecode=3)
Thanks for any helps



Edited by Afi83 - 04 Nov 2009 at 11:07pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 05 Nov 2009 at 6:27am
not sure what you are asking, do you need to calculate the average for each student?  As to the conditional calculation based on a code, you can use a formula.  In the formula would add each value, and probably keep a counter (both shared variables) and then in the footer, display /calculate the new value if the flag is set.
 
shared numbervar vSum;
shared numbervar vCount;
for the detail:
if (some condition is met) then (
  vCount := vCount+1;
  vSum := vSum +{table.Grade};
);
 
for the footer:
shared numbervar vSum;
shared numbervar vCount;
if {table.field}= (flag value, like 3) then
  vSum / vCount;
 
something like that, I am sure that there is more to the calculation, but this would be for a simple average, you can adjust as you need.
 
HTH
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.031 seconds.