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

Convert Number to String

Status
Not open for further replies.

elf1

Technical User
Jun 6, 2001
43
US
Hi,

I am having problems with the following formula:

If {POR_VendorPriceLevel.DiscountMarkup1} <> 0 then
{POR_VendorPriceLevel.DiscountMarkup1}
Else &quot;n/a&quot;;

The formula expects to find a number vs string &quot;n/a&quot;.
Can you help?

Thank you so much,
Lisa


 
In order to have &quot;n/a&quot; as one of your possible results you'd have to convert your field (after the &quot;then&quot;) to a string:

If {POR_VendorPriceLevel.DiscountMarkup1} <> 0 then
totext({POR_VendorPriceLevel.DiscountMarkup1})
Else &quot;n/a&quot;;

The alternative results of an if-then have to be of the same datatype.

-LB
 
Try,

If {POR_VendorPriceLevel.DiscountMarkup1} <> 0 then
ToText({POR_VendorPriceLevel.DiscountMarkup1})
Else &quot;n/a&quot;;

That's assuming there's always a numeric value in the DiscountMarkup1 field.

Peter Shirley
 
Hi,

The formula you suggested worked great to get the N/A's to print when the numeric field was zero; but I need your expertise to get the proper format (.0000) when a number <> 0 is present in that field.

How do you format a numeric field in a formula?

Thank you very much,
Lisa
 
Try this:

If {POR_VendorPriceLevel.DiscountMarkup1} <> 0 then
totext({POR_VendorPriceLevel.DiscountMarkup1},3, &quot;&quot;)
Else &quot;n/a&quot;;

The &quot;3&quot; sets the number of decimal places, and the &quot;&quot; removes the comma separator. If you want the comma separator, then use:

If {POR_VendorPriceLevel.DiscountMarkup1} <> 0 then
totext({POR_VendorPriceLevel.DiscountMarkup1},3)
Else &quot;n/a&quot;;

-LB
 
Tek-Tips is Awesome!
Thank you so much for solving my formula problem.

Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top