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

Finding the Maximum Average 1

Status
Not open for further replies.

khoke

Programmer
Jul 8, 2005
20
US
I am calculating average costs, and need to determine the maximum "average cost."
I have average costs calcuating per group, and want to determine which one is the greatest. Everytime I try to find the average on a calcualtion, I get an error message, "Field cannot be summarized." Is this even possible?????

Maximum ({@AverageCost})


@AverageCost = {@TotalPrescriptionCost}/{@TotalPrescriptions}


{@TotalPrescriptionCost} = SUM({@PrescriptionCost},{@MedicalDirectorName})

{@TotalPrescriptions} = count({Billing.DrugName}, {@MedicalDirectorName})

THANKS!!!!!!!
Kelly

 
At the {@MedicalDirectorName} group place the following formula:

numbervar MaxAvg;
If @AverageCost > MaxAvg then
MaxAvg := @AverageCost

Now you can refer to this variable in later formulas as:

numbervar MaxAvg;
"the maximum average is " & MaxAvg

-k
 
That works; however, I need to format (bold) the max value within the report. So, the formula will bold every value that is the max value at the time the record is read. I think the only way I can get this to work is through a subreport, and pass the value to the main report....
Thanks!
 
No, you don't need to use a subreport, and subreports are generally BAD ideas.

I've no idea where you intend to display the results, but you can conditionally bold fields.

-k
 
You could either use a subreport in the report header and then share the maximum average, or you could create a SQL expression that results in the average per group and then you would be able to highlight the maximum easily. If you want help with that, you need to identify your CR version, the {table.fields} used in the average, and your record selection criteria. If anything involves formulas, you must supply the contents of the formulas.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top