I am doing a profit percent report. What do I do if I have negative amounts? My forumula pops up with the division by zero error. What do I need to add to the end to correct this.
I have a similar problem. I am trying to calculate % complete. and used the above formula...however, I get a zero result.
Here is my formula:
If not(isnull({@BAC}))
and
{@BAC} <> 0 then
{@BCWP}/{@BAC}
else
0
The funny thing is that when I run my report...I have zero values for @BAC in some areas but all of my % complete calculations show 0. Could the fact that I am dividing formulas be the problem??
I don't seem to have a problem with @BAC, it extracts the correct data...the problem I am having is when creating a % complete formula using @BAC as the denominator:
If not(isnull({@BAC}))
and
{@BAC} <> 0 then
{@BCWP}/{@BAC}
else
0
It took care of the divide by zero error but now all my results are 0.
If isnull({@BAC}) //I don't think that this is ever the case
OR // NOT AND
trim(totext({@BAC})) in ["0",""] // Check for blank
then
"0.0"
else
totext(({@BCWP}/{@BAC})*100,6,"" //Parenthetical error and added precision
Note that the AND would never evaluate correctly.
I didn't review all of your post, but I'm confident that you haven't explored your data fully as my original post was correct.
If {@BCWP} is zero, then you'll get zero, and if you haven't exposed enough decimal places, then the number may appear to be zero when it is just a small number, as totext may lose precision.
I've no idea why you're converting this to a string, just use:
If isnull({@BAC})
OR // NOT AND
{@BAC} = 0
then
0
else
({@BCWP}/{@BAC})*100
Right click the result and format the number to have greater decimal precision.
Also place the
{@BCWP}
{@BAC}
fields alongside so you can see what they contain.
I guess I forgot the braces, or they were stripped in the redo of PGTEKS formula:
If isnull({@BAC}) //I don't think that this is ever the case
OR // NOT AND
trim(totext({@BAC})) in ["0",""] // Check for blank
then
"0.0"
else
totext(({@BCWP}/{@BAC})*100,6,"" //Parenthetical error and added precision
If isnull({@BAC}) //I don't think that this is ever the case
OR // NOT AND
trim(totext({@BAC})) in ["0",""] // Check for blank
then
"0.0"
else
totext(({@BCWP}/{@BAC})*100,6,"" //Parenthetical error and added precision
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.