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

Should be simple formula

Status
Not open for further replies.

lbizzell

Technical User
Apr 22, 2005
30
US
Hi -
I've got a group GroupName ({co.cust_num}) and I want to change the output based on the customer number. I've created the following formula and placed it in the group header, but all I return is false. Any ideas? Crystal 9, SQL

Example:
if GroupName ({co.cust_num}) ="0100000" then "Lowe's" else
"false"

Thanks-
Laurie
 
Why are you wrapping 0100000 in double quotes? Try this

if ({co.cust_num} = 0100000 )then "Lowe's" else
"Other"

Kchaudhry
 
I keep getting the "A string is required here" error.
Thanks-
Laurie
 
What type of field is {co.cust_num}?
If it is a string field then try:

if ({co.cust_num} = "0100000" ) then "Lowe's" else
"Other"

Otherwise, provide the infromation.

Kchaudhry
 
Or try:

if val({co.cust_num}) =100000 then "Lowe's" else
totext({co.cust_num},0,"")

So if it isn't Lowe's, it will tell you what number is iin there.

Adjust once you get it working properly.

-k
 
You keep getting false because there are no matches to the string "0100000". You haven't provided any sample data, so I don't know about that leading zero there.

What happens when you roll with
Code:
if ToNumber({co.cust_num},0,"") = 100000 
then "Lowe's" 
else "false"
Naith
 
kchaudhry - its a string [7]
this formula produced "Other"

if ({co.cust_num} = "0100000" ) then "Lowe's" else
"Other"

synapsevampire - tried yours and got "Too many arguments have been given to this function"

Naith - same result as synapsevampire

Sample data:
10001 FIRST DATA CORPORATION
2645 FISCHER & PAYKEL APPLIANCES
2745 FLOOR PRODUCTIONS
10011 FLOOR SERVE
2794 FOSTERS INC.

The names are not in any table, hence the need for the if/then statement.

Thanks for all the suggestions...
Laurie

 
Try a different one (I wonder whether the ' is the culprit in Lowe's) and maybe add trim() to eliminate problems with extra spaces:

if trim({co.cust_num}) = "2745" then "FLOOR PRODUCTIONS"

-LB
 
Sorry, that comment about the "'" didn't make any sense.

-LB
 
It worked! Thanks so much... now if I can get it to work for all of them!

Laurie
 
Well the formula is only looking for 0100000 and you didnt include this in the sample data so the result "other" seems right to me.

Please change your formula to something like this:

if ({co.cust_num} = "0100000" ) then "Lowe's" else
if ({co.cust_num} = "10001") then "FIRST DATA CORPORATION" else
if ({co.cust_num} = "2645" then FISCHER & PAYKEL APPLIANCES"
else "Other"

You should get the idea. Use the above logic to add all your conditions.

Kchaudhry
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top