Solved

If Then Else Then Sum

Posted on 2009-04-15
4
529 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
ID: 24149444
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
ID: 24154368
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
ID: 24157225
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
ID: 24164312
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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