?
Solved

If Then Else Then Sum

Posted on 2009-04-15
4
Medium Priority
?
533 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
[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
4 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 189 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 35

Assisted Solution

by:James0628
James0628 earned 186 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 35

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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
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…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

770 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