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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to do this: IF statement?

Status
Not open for further replies.

bloomlight

IS-IT--Management
Jun 12, 2006
149
US
I have to make a crystal report with data if field A matches first 2 letters of field B. This is what I want to do:

field A: field B
========= ========
PT PTNB
PT
PTNN
PTEV
PTS
SW SWS
SWN
HH HH

For SQL coding, I can make a query similar to this: field B like 'PT%'. But don't know how to set up in Crystal. Any suggestions? Thanks.
 
You can create a formula that does a Left({field B} , 2) and group on that formula. Likewise, if not all your field A's have a matching field B, then you could filter by your report with the statement '{field A} = Left({field B}, 2).

I hope this helps.
 
Another question: How to filter out some of the names in field B?

for example, I want all above listed except "PTNB" and "PTNN". How can I do that?

Thanks.
 
in the 'grouping' formula you already have from kray, add a check to exclude the unwanted values:

IF ({Field B} in ["PTNB", "PTNN"])
THEN ""
ELSE Left({field B} , 2)
 
I coded the following, but got error message saying that "A boolean is required here". What was wrong? Thanks.

IF Left({ServiceType}, 2) = {DiciplineID} and {{ServiceType} in ["PTNB", "SNNB", "SD"]}
THEN ""
ELSE Left({ServiceType}, 2)

 
you have {} instead of () around this {ServiceType} in ["PTNB", "SNNB", "SD"]



you could also add parenthesis to ensure clear logic:

IF ((Left({ServiceType}, 2) = {DiciplineID}) and ({ServiceType} in ["PTNB", "SNNB", "SD"]))
THEN ""
ELSE Left({ServiceType}, 2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top