Link to home
Start Free TrialLog in
Avatar of maston57
maston57

asked on

Average Formula excluding zero records

I'm new to Crystal Reports 9 and am trying to create a report that summarizes the results of our customer survey.  Column one is the score for each record (0 - 5).  I need to calculate the average ecluding the records containing a zero. for example i have 391 records of which 5 contain zero. The total sum of the entries in the column is 1802. If I exclude the 5 records containing a zero the average for the column should be 4.67.

I tried the formulas located in your answer section but they bring back an average of 4.61.  I'm not sure what I am doing wrong and being new I can spend forever trying to figure it out - can you help? Thank you.
SOLUTION
Avatar of ebolek
ebolek

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ebolek
ebolek

Sorry inmy post I wrote operation summary, it should be average. You can either write your formulas as bdreed said or use running total functionality offered in crystal to do the task like I said. Whatever is good for you

Regards
Emre
As ebolek said, both approaches will work for you.

The basic difference between the two is when Crystal executes them.
The method I presented will calculate the average before the records are printed, so you would be able to display the result in the Report Header or Report Footer.
The running total method calculates as the records are printing, so it is only accurate at the end, so the Report Footer is where it needs to be displayed.
Avatar of maston57

ASKER

You can't imagine how much time and frustration you have saved me! Both of these answers work but I'm thinking (and please correct me if I'm wrong) that I should use the two part formulas submitted by bdrred35 if I want to add groups to my report and then average the groups? Can the formula be modified to work for groups with a grand total average at the end?

P.S. This is my first time using this website so if I'm suppose to ask these questions in another area - please advise. Thank you so much!!
You still can use both. As bdreed say it depends where you want to display summary totals,Runnng totals can do grand totals, sum and lots of mathematical functions. But you can adjust bdreeds formula to do that too. It is about what you are comforrtable with and where you had to display it.

With my solution, create another formula for each grouping that you want to see the average at

Lets say you were grouping by Customer.

You would still use the @CountVals formula the same way.
You would also still use @CalcAvg in the report Footer for an overall average.

You would then create another formula to place in the Customer grouping like this:

@CalcCustomerAvg
Sum({table.score},{table.customer}) / Sum({@CountVals},{table.customer})
You're my hero! Thank you!