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!

DIVISION BY ZERO 3

Status
Not open for further replies.

edteck

MIS
Feb 23, 2000
47
IE
how can I get round the error message &quot;division by zero&quot;.<br>
In essence I need to calculate the percentage by which an invoice exceeds its original value. (x-y)/y*100. Some order values have zero values, hence the error message.
 
Division by zero is mathmatically &quot;undefined&quot;, so hence all arithemetic operations that run into it generate (or should generate) an error mesage. In your situation, it seems like you want to show the percentage change. However, if the {y} amount is zero, the percentage change is not relevant, so maybe you should show something like &quot;N/A&quot; in that case.<br>
To calc the percent;<br>
If {y} &lt;&gt; 0 then<br>
{x}-{y}%{y} // or ({x}-{y}/{y})*100<br>
Else<br>
0 // this result will be suppressed, but it is here so that the formula is logically complete<br>
<br>
Suppress this formula, using the following formula<br>
{y} = 0<br>
<br>
Now, part two. To indicate &quot;N/A&quot;, just drop &quot;N/A&quot; into a text box and format to suppress with the following formula. <br>
{y} &lt;&gt; 0<br>
Put the text box on top of the first formula. Should work. <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top