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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compute, Display Average 1

Status
Not open for further replies.

MikeCopeland

Programmer
May 21, 2007
91
US
Using CR8.5...
It seems to simple, but I can't get it to work. I have a report that looks like this:
Name Rate Stage Date
Barber, Alex 50% Review 03/26/2007
Barber, Alex 30% Review 03/26/2007
Barber, Alex 40% Review 03/26/2007
Barber, Alex 50% Discharge 04/21/2007
Barber, Alex 90% Discharge 04/21/2007

and I wish to average the Rate column for each group (Alex Barber is one group, so I wish to compute the average: 52). I tried to create a formula:

WhilePrintingRecords;
Average({ClientISPDetail.CurrentMeasure})

and place it in the Group line, but its output is incorrect (it's ALWAYS 5.97...). I must be doing something very wrong, but I'm lost as to what it is... Please advise. TIA
 
Try:

WhilePrintingRecords;
Average({ClientISPDetail.CurrentMeasure},{table.name})

-k
 
Sorry, I don't understand. I tried the following:
Average({ClientISPDetail.CurrentMeasure}, {ClientISPDetail.CurrentMeasure})
and got a syntax error ("The summary/running total field could not be created.") - so I must be completely misunderstanding your reply.
All I want to do here is compute the average of ClientISPDetail.CurrentMeasure, which is a numeric data field, for each group of Clients. In the example data, I have 5 records that have values of 5, 3, 4, 5 and 9, and I wish to compute the average of those values (5.2) and display it as 52% - and so forth for all Clients. (If I can _compute_ the correct value, I can surely scale it from 5.2 to 52 for display - this isn't my problem...it's the computation that's wrong.)
I apologize for not explaining this detail in my original post, but I don't think that's my main problem: I suspect there's something wrong with how I'm using the formula and/or resetting something in the use of the built-in Average function. (Or else I'm completely off-base in my use of this element...)
 
The 2nd argument of the average function must be the field you are grouping by. From your original post it sounds as though you grouped by person ("Alex Barber is one group"). So the field that represents this grouping in your report is the field you need to use as the second argument of the Average function.

Average(field to average, grouping field)

mrudolph
 
Well, the "grouping field" I'm using is a derived field (via a function I've written) that combines a Client's Last and First names. It's called "@fullName" (it's "BarberAlex" in this case). I'm breaking groups with it for a 2nd-level Group in order to compute this value and insert a line at the end of each Group with the computed value. Here I want to have the line display "Alex Barber's Average Rate: 52%".
Now, as I understand it, I should be using @fullName as the 2nd argument to the Average function - is that right? TIA
 
right, by grouping field, I meant which ever field you are grouping by, whether it is a database field or formula field such as you have done. So if you have grouped on the @fullname formula field, then that is the field you will want to use as the second argument with your Average function.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top