Solved

weighted average function that excludes zeros?

Posted on 2006-10-31
6
472 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

747 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

12 Experts available now in Live!

Get 1:1 Help Now