Solved

weighted average function that excludes zeros?

Posted on 2006-10-31
6
475 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
  • 2
6 Comments
 
LVL 28

Accepted Solution

by:
bdreed35 earned 500 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 100

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 100

Expert Comment

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

mlmcc
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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