Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

crystal report average formula problem 1

Status
Not open for further replies.

wonderhands

Programmer
May 13, 2002
19
GB
hello i have a report 1 one group.

In this report i have an average total worked out fine.

Here comes the beep....

I need 2 display the average total for totals above £3500
and average total for totals below £3500.

for example given the following data:-

1000
2000
3000
4000
5000
6000

I would like to show overall average: 3500 (i can do this one)

Also

the average for totals above 3500 ::: showuld show 5000.
the average for totals below 3500 ::: showuld show 2000.


I am using crystal reports for .net.

Anyone help.

T.I.A








 
Well you can do this with formulas....much like a 3 formula sum

In the Group header that repeats the average or report header if this is done once place this suppressed formula

//@Init (suppressed)

WhilePrintingRecords;
Numbervar TotalHigh := 0;
Numbervar TotalLow := 0;
Numbervar CountHigh := 0;
Numbervar CountLow := 0;

In the details section

//@CalcTotals (Suppressed)

WhilePrintingRecords;
Numbervar TotalHigh ;
Numbervar TotalLow ;
Numbervar CountHigh ;
Numbervar CountLow ;

If {table.value} >= 3500 then
(
TotalHigh := TotalHigh + {table.value} ;
CountHigh := CountHigh + 1;
)
else
(
TotalLow := TotalLow + {table.value} ;
CountLow := CountLow + 1;
);


In the footer for display

//@DisplayAvgHigh

WhilePrintingRecords;
Numbervar TotalHigh ;
Numbervar CountHigh ;

if CountHigh <> 0 then
TotalHigh / CountHigh
else
0;

You make a similar formula for Low Average.

That is all there is to it.


Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top