Solved

weighted average function that excludes zeros?

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

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

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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

919 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

15 Experts available now in Live!

Get 1:1 Help Now