Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

weighted average function that excludes zeros?

Posted on 2006-10-31
6
Medium Priority
?
483 Views
Last Modified: 2008-02-01
Is there a weighted average (or just plain old average) formula or function in Cyrstal Reports XI that exludes zeros?

I have several formula fields that I created were zeros appear.  I want to do an average or weighted average on these detail field for group 1 but the presence of zeros is throughing off the true number.  The reason I have zeros is b/c the formula field requires that the if statement must return a "0" if the statement is false.  Even if I leave out the part "Else 0" I still get zeros were the if statement is false.

{trade.settle_i} is the settlement date of the investment
{trade.days_i} is the term of the investment, i.e, 90 days, 365 days, etc. represented by just numbers like 90, 365, etc.

If {trade.settle_i} in dateadd("yyyy",-5,minimum(LastYearYTD)) to dateadd("yyyy",-5,maximum(LastYearYTD)) then
    {trade.days_i}
Else
    0

Any input would be greatly appreciated!
Brian
0
Comment
Question by:IO_Dork
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
bdreed35 earned 2000 total points
ID: 17844644
There is a weighted average function, at least in XI.
I think what you need is 3 formulas, one of which is the one you posted above.
The second is very similar:

If {trade.settle_i} in dateadd("yyyy",-5,minimum(LastYearYTD)) to dateadd("yyyy",-5,maximum(LastYearYTD)) then
    1
Else
    0

In the 3rd formula, you can put your weighted average function:

weightedaverage({@tradedaysvalue},{@tradedayscount})
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 17846758
Agree.  

Do you need the data fields that are outside your date range for the rest of the reort?

If not use filtering or selection to limit the data in the report to what you want then the average will work.  Check
  REPORT --> SELECT EXPERT
Use a formula
{trade.settle_i} in dateadd("yyyy",-5,minimum(LastYearYTD)) to dateadd("yyyy",-5,maximum(LastYearYTD))

mlmcc
0
 

Author Comment

by:IO_Dork
ID: 17852813
Yes, I do need the data b/c I used this formula to create YTD columns for years 2000 through 2006.
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 17853423
Then you will need to use a formula similar to bdreed's suggestion

mlmcc
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

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. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

636 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