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

Simple If/Then Statement 2

Status
Not open for further replies.

jlhart76

Technical User
Feb 22, 2005
20
0
0
US
I'm trying to create an if/then statement, but am having trouble. The fields are:
A = Total # of consumers during month
B = Total # of consumers meeting criteria X

I need a statement that says if A=0, then return a value of "N/A". Otherwise, divide B from A.
I've tried several different ways, but I keep getting "A string is required here" error message. Please help.
 
Both sides of the if/then/else need to return the same data type, so you need to convert the result of the division to text:

if {table.total_consX} = 0 then
"N/A"
else
totext({table.total_cons}/{table.total_consX},2)

~Brian
 
If you need to work with the result as a number, an alternative would be to use a formula for display purposes only:

if {table.total_consX} = 0 then
"N/A"
else
totext({table.total_cons}/{table.total_consX},2)

Then you can create a formula for use with calculations such as:

if {table.total_consX} = 0 then
0
else
{table.total_cons}/{table.total_consX}

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top