Advertisement

12.17.2004 at 07:01AM PST, ID: 21246125
[x]
Attachment Details

handling nulls in running totals

[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.4
Tags:

crystal, null, reports, running, total

Its been I while since I’ve been here, but this time I’m back to GET a bit of advice.  I’ve got a situation that I’ve got a resolution for, but I don’t like it, and want to make sure im not missing anything.  Here’s the set up

Crystal 8.5.0.217
Calculating Statistics in a Sub-Report

I’ve got 4 Running totals, 3 of which will be added together to create the denominator of a division stat.  2 of the three will, 9 times out of 10, be Null.  This is because the running total only evaluates on specific criteria (reporting off a 4GL product, evaluation formula is looking for a specific summary account).  As you know, a null value in an aggregate function returns a null value, so I have to either weed out the nulls or set the nulls to zero. My first solution was IF..THEN..ELSE.  But that gets pretty hairy:

IF IsNull({#value 1}) = True AND IsNull({#value 2}) = True THEN
  (IF {#value 3} <> 0 THEN
    {#value 4}/{#value 3}
   )
ELSE IsNull({#value 1}) = True AND IsNull({#value 2}) = False THEN
  (IF ({#value 3}+{#value 2}) <> 0 THEN
    {#value 4}/({#value 3}+{#value 2})
   )
ELSE IsNull({#value 1}) = False AND IsNull({#value 2}) = False THEN
  (IF ({#value 3}+{#value 2}+{#value 1}) <> 0 THEN
    {#value 4}/({#value 3}+{#value 2}+{#value 1})
   )
ELSE IsNull({#value 1}) = False AND IsNull({#value 2}) = True THEN
  (IF ({#value 3}+{#value 1}) <> 0 THEN
    {#value 4}/({#value 3}+{#value 1})
   )

The assumption here is that {#value 3} will never be null. Then in the future, if new values are added to the calculation, the ELSE statements needed to be added will go up exponentially by the number of values in the denominator minus 1.

The other option is to create formulas that check the running total to see if its null, if it is, set it to zero, then use that formula in the calculations.  This way, I don’t have to check for nulls, just that the three columns combined don’t equal 0

I’m sure the easiest option would be to just add all these running totals together into the same running total field, but that cant be done since each value is used else where in the report and must be segregated from the other(Sar-Box compliance).

Which do you feel is the best solution or better yet, what is a more efficient way to do this.  Essentially what I need to do it set the default value of a running total to zero, not just in the report display but in the logic of the report.

Thanks in advance for the help.
mnye
Answered By: mlmcc
Expert Since: 11/30/2000
Accepted Solutions: 10649
Computer Expertise: Advanced
mlmcc has been an Expert for 8 years1 month, during which he has posted 55609 comments and answered 10649 questions. mlmcc is just one of 785 experts in the Crystal Reports Software Zone. 2 experts collaborated on this answer, which was graded an "A" by the asker.
 
 
20081119-EE-VQP-47