Print Page | Close Window

Average of a summarized formula field

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=19507
Printed Date: 03 May 2024 at 3:18am


Topic: Average of a summarized formula field
Posted By: bash
Subject: Average of a summarized formula field
Date Posted: 06 May 2013 at 10:21am
Hi,
I would like to know how to get the average of a summarized field. For example. I have a count field of "total_Records" which is string. I would like to get the average of this amount based on business days.
 
I feel it is not a simple average function as the business days condition involved. I Appreciate any helpful hand to sort out this.
 
Thanks to all.



Replies:
Posted By: lockwelle
Date Posted: 06 May 2013 at 11:02am
well, if it is not a simple average, I would create my own running total using variables, though you might be able to accomplish this using Running Totals...but they are DBlanks forte.

for variables, you typically have 3 sets of formulas:
initialize/reset, usually in a group header:
shared numbervar x:=0;
"" // this will hide the 0 zero on the report

a summary value, usually in a group footer;
shared numbervar x;
x

so far, pretty easy...now the hardest one, which might be simple
in the detail section, the accumulator
shared numbervar x;
if {table.field} then
x := x +1;
"" //again will hide the running value.

now the question is what to put in the 'if' statement...
I would try the DayOfWeek() function and do something like this:
if DayOfWeek({table.field}) > 1 and DayOfWeek({table.field}) < 7 then
x := x + 1;
""

this should you a count of weekdays, that you can then use to figure out your average.

HTH


Posted By: bash
Date Posted: 06 May 2013 at 4:51pm
Thanks a lot for your input. I will try this and update you.



Print Page | Close Window