?
Solved

weighted average function that excludes zeros?

Posted on 2006-10-31
6
Medium Priority
?
481 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

752 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