Solved

Average Formula excluding zero records

Posted on 2004-09-30
8
2,263 Views
Last Modified: 2011-12-05
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.
0
Comment
Question by:maston57
  • 3
  • 3
  • 2
8 Comments
 
LVL 10

Assisted Solution

by:ebolek
ebolek earned 200 total points
ID: 12189499
you can click on insert
running total

1.field to summarize
2. operation summary
3. check the group
4. in the evaluate : check use a formula and enter this in x2:
{table.field} <> 0

Click OK
0
 
LVL 28

Accepted Solution

by:
bdreed35 earned 300 total points
ID: 12189512
Can you post what you are using in the formulas?

I would take this approach:

Create one formula to count the non zero's and place it in the details section and suppress it:

@CountVals
if {table.score} > 0 then
    1
else
    0

Create another formula that will calculate the average in the Report Footer:

@CalcAvg
Sum({table.score}) / Sum({@CountVals})

That should get you close.  Let me know if you need anymore help.
1
 
LVL 10

Expert Comment

by:ebolek
ID: 12189555
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
0
 
LVL 28

Expert Comment

by:bdreed35
ID: 12189642
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.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:maston57
ID: 12191283
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!!
0
 
LVL 10

Expert Comment

by:ebolek
ID: 12191306
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.

0
 
LVL 28

Expert Comment

by:bdreed35
ID: 12191362
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})
0
 

Author Comment

by:maston57
ID: 12193105
You're my hero! Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Display group header even if no detail records 9 64
SQL Expression in Crystal Reports 19 51
Formatting a Crystal Reports Report 9 77
Crystal Reports 9 and Subreports 3 52
Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now