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!

Average Calculation On Text Field 2

Status
Not open for further replies.

nerdlinger

Programmer
Apr 8, 2001
14
US
I need to get an average on a field within a group. The field I need to average is a character type and the values that it can contain are the numbers 1-10 and the text "Don't Know" and "Refused To Answer" I need to weed out the text strings and get a sum of all the remaining in the group so I can divide that by the totalcount for the group...help

Thanks
 
Use the val() function in a formula to convert the text to a number (the text will return 0). Sum this formula.

Now create a second formula that says:

if the Val() formula is > 0
then 1
else 0


Now sum this formula as well. This sum will equal the "count" of records with a response. Now divide the first sum by the second sum (which gives the count) and you will get your average. Ken Hamady
Crystal Reports Training/Consulting and a
Quick Reference Guide to VB/Crystal (including ADO)
 
Okay, I feel stupid, but I'm trying to do the same thing Nerdlinger is, and I am trying to implement what Ken has suggested, and I'm lost as to how to Sum a formula field. Sorry if you've already covered this, but this is the closest converstation I've come to what I want to do that I've been able to find.

TIA
 
It is very easy to Sum a formula field, as long as the formula is eligible for summing. Put the formula on the detail band and then go the insert menu and use Insert - Grand Total/Subtotal. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Thanks Ken. Apparently I have a formula that is not eligible for summing, but I will put this info to good use anyway!
 
If you want to know why it is ineligible, post the formula. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
I have 2, neither of which is working. The formulas are: Val ('{TICKETACTIVITY.UNITS}')
and
if Val('{@UnitValue}') > 0
then 1
else 0

Thanks.
 
Why do you have the field names in quotes inside the parens?
Remove the quotes and things might work. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Because it's looking for a string? I don't know. I'll just try something else.

Thanks.
 
try:

if {TICKETACTIVITY.UNITS} > 0
then 1
else 0 Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Guide to Crystal in VB
- tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top