Solved

If Then Else Then Sum

Posted on 2009-04-15
4
526 Views
Last Modified: 2012-06-27
I have this criteria - where Table.FieldA does not equal 'I' then 1 else 0.  Then sum the information from Table.FieldB based on the If/Then statement.  I have a report where I need to put in the information for the opposite information, too - where Table.FieldA does equal 'I' then 1 else 0 and so on.
If {Table.FieldA} <> 'I' Then 1 Else 0 Then Sum ({Table.FieldB}).  When I do this I get a "the ) is missing" message box and it highlights "Then" when this happens.

How do I correctly state this formula?  Thanks.
0
Comment
Question by:kristibigo
  • 2
4 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 63 total points
Comment Utility
You are trying to combine 2 actions.  You need to do this in 2 steps.
Try it this way

Create a formula
If {Table.fieldA} <> 'I' then
    1
else
    0

Save the formula
Drop the formula onto the report
Right click the formula field on the report
Click INSERT --> SUMMARY
Set it for a SUM
Put it in the report footer
You can then delete the formula field from the report

mlmcc
0
 
LVL 34

Assisted Solution

by:James0628
James0628 earned 62 total points
Comment Utility
I'm not entirely sure what you're trying to do, but if you're trying to get the sum of a field, as opposed to a count, then forget the 1 or 0 stuff.

 If you want the total of FieldB from the records where FieldA is not 'I', create a formula like the following, put it in the detail section and then insert a summary for that field:

If {Table.FieldA} <> 'I' Then
  {Table.FieldB}
Else
  0


 If you also want a total for FieldB from the records where FieldA _is_ 'I', then create another formula and do a summary on it too:

If {Table.FieldA} <> 'I' Then
  0
Else
  {Table.FieldB}


 James
0
 

Author Comment

by:kristibigo
Comment Utility
Although these both solve the issue, it is hard to know exactly how to answer my question without knowing everything about the issues at hand.  
I have discovered the following solution:
If {Table.FieldA} <> 'I' and {Table.FieldB} in [0 - 5] Then 1 Else 0
I then went to the Insert>Summary and set it for Sum, and it then tallied correctly.
Thank you.
0
 
LVL 34

Expert Comment

by:James0628
Comment Utility
OK, so you weren't looking for a total of FieldB, or a straight count.  You wanted a count of the FieldB values between 0 and 5, when FieldA was not "I".

 IAC, glad we could help you figure it out.

 James
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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. …
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 …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

743 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

16 Experts available now in Live!

Get 1:1 Help Now