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

Help with 'if then else' formula 1

Status
Not open for further replies.

skystar70

Technical User
Nov 3, 2006
40
US
Hello.

I am on v 9 and have created the following formula:

If {st_wbs99.description} = "Extra Small" then
50000
Else If {st_wbs99.description} = "Small" then
100000
Else If {st_wbs99.description} = "Medium" then
250000
Else If {st_wbs99.description} = "Large" then
500000
Else if {st_wbs99.description} = "Extra Large" then
1000000
Else 0

I do not get an error when creating the formula. The problem is that I do not get a zero (last part of formula) on the records which do not conform to the other if statements. Meaning, my else statement does not seem to be working. The result is a null for those records without the Extra Small, Small, Medium, Large, or Extra Large designations.

Any ideas on why my last Else statement does not work??

Thanks!

Skystar
 
You must specifically test for nulls in the first clause of your if/then like this:

If isnull({st_wbs99.description}) then
0
Else If {st_wbs99.description} = "Extra Small" then
50000
Else If {st_wbs99.description} = "Small" then
100000
Else If {st_wbs99.description} = "Medium" then
250000
Else If {st_wbs99.description} = "Large" then
500000
Else if {st_wbs99.description} = "Extra Large" then
1000000
Else 0

-LB
 
Can it be null? If so, then you have to process it first.

If isnull({st_wbs99.description}) then
0
Else If {st_wbs99.description} = "Extra Small" then
50000
Else If {st_wbs99.description} = "Small" then
100000
Else If {st_wbs99.description} = "Medium" then
250000
Else If {st_wbs99.description} = "Large" then
500000
Else if {st_wbs99.description} = "Extra Large" then
1000000
Else 0
 
Perfect. Yes, you were both right, it is a null and I always forget that nulls are special. :)

This worked great. Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top