Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: How to Calculate average for datediff Post Reply Post New Topic
<< Prev  Page  of 2
Author Message
leke
Newbie
Newbie


Joined: 04 Aug 2014
Online Status: Offline
Posts: 6
Quote leke Replybullet Posted: 08 Aug 2014 at 5:46am
Originally posted by lockwelle

which goes back to my original response.
Since all of the data is not 'intrinsic' to the raw data...or all on the same row of data (previous is not on the same row) then the formula cannot be aggregated by CR.

The way around this is to used shared variables...maybe running totals (they are not my forte, but DBlank's)

with shared variables you to something like:
group header
shared numbervar cnt:=0;
shared numbervar sm:=0;
""

group footer, where you want to display the average:
shared numbervar cnt;
shared numbervar sm;
if cnt>0 then
sm/cnt
else
0

details, this is where the fun is...
probably just update your lapsed time formula to be something like
shared numbervar cnt;
shared numbervar sm;

if (some criteria) then (
cnt := cnt +1;
sm := sm + ({table.field}-previous(table.field));
)

HTH
""


I'm leaning towards this option. Create a running totals of the time then calculate average of that. I initially wanted a way to create a formula that calculated the average of the datediff.


IP IP Logged
<< Prev  Page  of 2
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