Solved

If Then Else Then Sum

Posted on 2009-04-15
4
528 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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…
Hot fix for .Net Crystal Reports 10.2.3600.0 to fix problems with sub reports running on 64 bit operating systems ISSUE: Reports which contain subreports fail with error "Missing Parameter Value" DEPLOYMENT SERVER OS: Windows 2008 with 64 bi…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.

832 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