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!

Formula for 'contains' 1

Status
Not open for further replies.

JCook23

Technical User
May 19, 2004
39
US
I want to write an if then statement:

if (field) CONTAINS 'Apollo' then "APOLLO" else (field)

What is the syntax for contains?

This is a field that may include several numbers before and after 'Apollo'.

Thanks for any input,

Jeff C.
 
Try:

if instr({table.field},"Apollo") <> 0 then "APOLLO" else {table.field}

-LB
 
Ok, but can I do something like this?

if {glcshm.fcpaidby} = 'V' then "Credit Card" else
if {glcshm.fcpaidby} = 'M' then "Credit Card" else
if {glcshm.fcpaidby} = 'K' then "Check" else
if {glcshm.fcpaidby} = 'E' then "EFT" else
if instr({glcshm.fcreferenc}, "APOLLO") <> 0 then "APOLLO" else {glcshm.fcreferenc}

I want this to be a group. I have it working until I get to the different field with the APOLLO statement. I will also need t add the same thing for "ORBIAN" and "CORPORATE".

I need subtotals for Checks, CC's, EFT's, Apollo's, Orbians, etc. Apollo and Orbian also fall under CC or Check or EFT, but those need to be in there own group. Does this make any sense?

Jeff
 
What would you want to happem if a record had {glcshm.fcpaidby} = 'V' and glcshm.fcreferenc contains apollo ?

would this be Credit Card or APOLLO ?





Gary Parker
MIS Data Analyst
Manchester, England
 
If you are trying to create separate groups for Apollo, Orbian, etc., ONLY because you need subtotals for them, you don't need to do that. You could insert a group on {glcshm.fcpaidby} and then use running totals for Apollo and Orbian where you set the evaluation formula to:

instr({glcshm.fcreferenc},"Apollo") <> 0 //or "Orbian"

-LB


 
LB, I am thinking I need more than just subtotals. If it is Credit Card and Apollo, the amount cannot be part of the CC subtotal. I am also doing counts. Am I thinking correcting about the groups?
 
Try something like:

if {glcshm.fcpaidby} in ['V','M'] and
instr({glcshm.fcreferenc},"Apollo") = 0 and
instr({glcshm.fcreferenc},"Orbian") = 0 then "Credit Card" else

if {glcshm.fcpaidby} = 'K' and
instr({glcshm.fcreferenc},"Apollo") = 0 and
instr({glcshm.fcreferenc},"Orbian") = 0 then "Check" else

if {glcshm.fcpaidby} = 'E' and
instr({glcshm.fcreferenc},"Apollo") = 0 and
instr({glcshm.fcreferenc},"Orbian") = 0 then "EFT" else

if instr({glcshm.fcreferenc}, "Apollo") <> 0 then "APOLLO" else
if instr({glcshm.fcreferenc}, "Orbian") <> 0 then "ORBIAN" else
{glcshm.fcreferenc}

The instring function is case sensitive, so make sure that you use the case that is found in the database.

-LB
 
I was heading down this path with your help. Wasn't quite working until now. THANKS LB!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top