Author |
Message |
jjthed
Newbie
Joined: 15 Aug 2014
Online Status: Offline
Posts: 20
|
Topic: Average of a summary field Posted: 04 Sep 2014 at 12:40pm |
Hello,
I am just wondering how do I get the average of a formula?
For example in designer view:
group 1 unit price
group 2 formula (price/qty)
group 3 (average of group 2)- don't know how to do it??
What it looks like on the report:
Unit Price
$7
$10
$7
______
$8
Thanks!
|
IP Logged |
|
FrnhtGLI
Senior Member
Joined: 22 May 2009
Online Status: Offline
Posts: 347
|
Posted: 05 Sep 2014 at 4:17am |
You need a sum of the formula for Group 2, divided by the count of the records displayed in Group 2:
sum({@price/qty} , {@group2})/ count ({@price/qty} , {@group2})
|
|< /\ '][' ( )
|
IP Logged |
|
jjthed
Newbie
Joined: 15 Aug 2014
Online Status: Offline
Posts: 20
|
Posted: 05 Sep 2014 at 5:44am |
Thanks for the tip, but it gives me an error saying {@price/qty}cannot be summarized. Any suggestions?
|
IP Logged |
|
FrnhtGLI
Senior Member
Joined: 22 May 2009
Online Status: Offline
Posts: 347
|
Posted: 05 Sep 2014 at 7:10am |
Three Formula Manual Running total to calculate summary.
@INIT_Formula whileprintingrecords; global numbervar nPrice/QTY:=0;
@CALC_Formula whileprintingrecords; global numbervar nPrice/QTY:=nPrice/QTY + {@price/qty};
@DISP_Formula whileprintingrecords; global numbervar nPrice/QTY;
@INIT goes in Group2 Header @CALC goes on detail line where the summarizing needs to take place @DISP goes on the line where you want the Average to display.
You can suppress @DISP then create a field that is similar to the previous one: whileprintingrecords; global numbervar nPrice/QTY / count ({@price/qty} , {@group2})
|
|< /\ '][' ( )
|
IP Logged |
|
jjthed
Newbie
Joined: 15 Aug 2014
Online Status: Offline
Posts: 20
|
Posted: 05 Sep 2014 at 11:47am |
Hrm..... I tried few times, it kept giving me wrong number. I don't use detail section, so the unit price shows in my group 2 section. And this is my first time using a formula doing a manual running total, I am not sure where do I place all the formulas?
Many thanks!!
|
IP Logged |
|
jjthed
Newbie
Joined: 15 Aug 2014
Online Status: Offline
Posts: 20
|
Posted: 05 Sep 2014 at 11:49am |
Just to add, I know you mentioned that one goes to the header, but I don't have any place to put that...
|
IP Logged |
|
|