Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using If Then Statements

Status
Not open for further replies.

evalla

MIS
Dec 18, 2003
2
US
Sorry, I am beginner at using formulas with crystal reports. This question is pretty basic.

I am trying to run a formula on this field CI_INFO_FILE.CI_SEQ_NBR}that shows me values that contain a 1 only. In our transaction system, we can add more than one sequence #. Each seq # shows up on its separate area, but in our database there is only one available field name. Hope this makes sense.

Thanks,

Evalla
 
Evalla,

If I understand you correctly. Try this.

Create a new formula and put in the following.

Whilereadingrecords;
stringvar CI_SEQ_NBR;
if [CI_INFO_FILE.CI_SEQ_NBR} = 1 then CI_SEQ_NBR := CI_INFO_FILE.CI_SEQ_NBR}

Hope this helps

ken
 
Thanks Ken for the reply!

I am still having trouble using the formula. I left out some information in the original posting. In this report values 1 and 68 are available, and a record could contain both at the same time. I am trying to locate all the records that have a 1 only wihout the 68. Thanks!!

Eric
 
You have defined your problem very poorly.

You should give examples of the data you are looking for. In this case "reading between the lines" it appears that in order for a 1 and 68 to exist at "the same time" then you must be looking at a string containing these characters

If not so then redefine your problem properly....don't make us guess

You can try this formula IF I HAVE GUESSED CORRECTLY

//@FindTHEONE
WhilePrintingRecords;

If instr({CI_INFO_FILE.CI_SEQ_NBR},&quot;1&quot;) <> 0 and
instr({CI_INFO_FILE.CI_SEQ_NBR},&quot;68&quot;) = 0 then
{CI_INFO_FILE.CI_SEQ_NBR}
else
&quot; &quot;;

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
Eric,

The code I wrote before will only look for 1 and nothing else. The one below is the same but I made a change in case of field format differences.

Whilereadingrecords;
stringvar CI_SEQ_NBR;
if {CI_INFO_FILE.CI_SEQ_NBR} = 1 then CI_SEQ_NBR := totext(
{CI_INFO_FILE.CI_SEQ_NBR})


If you want to limit your report to show just the 1 then in select expert chose the name of this formula and set it to equal 1.

Ken
 
It sounds like you might be referring to a &quot;record&quot; to mean an account or an ID that might actually contain multiple records. Let's say that you are writing a report on customers, and that for any one customer {CI_INFO_FILE.CI_SEQ_NBR} might = 1, 68, or both as in the following display:

CustID Sequence Number
1 1
1 68
2 1
3 68
4 1
4 68

If your data is like this, and you want to choose the customer who ONLY has a Sequence Number of 1 (customerID = 2 in this example), then use a record selection formula of:

{CI_INFO_FILE.CI_SEQ_NBR} in [1,68]

And then create a formula {@oneonly}:

if {CI_INFO_FILE.CI_SEQ_NBR} = 1 then 0 else 1

Group on {table.customerID}. Then you could use a group select. Go to report->edit selection formula->GROUP and enter:

sum({@oneonly}, {table.customerID}) = 0

The other option, instead of a group select, is to suppress records by going to format section->group header, details, group footer->suppress->x+2 and enter:

sum({@oneonly}, {table.customerID}) <> 0

You would then need to use running totals for further calculations. If you use the suppression method, you would have to build in the opposite of the suppression formula into the evaluate based on a formula section of the running total.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top