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!

Formula Producing opposite to what I was expecting

Status
Not open for further replies.

JulianS

Programmer
Dec 10, 2001
9
GB
Am I stupid or what?

I have a formula (below) that is returning the opposite of what I am expecting. In this case {@FETCHBalanceOwing} - {@AgentClientTotal} does equal 0.

if {@FETCHBalanceOwing} - {@AgentClientTotal} <> 0 then
&quot;Discrepancy&quot;

I would not expect to see &quot;Discrepancy&quot; appear on my report but it does.

If I change the formula to:

if {@FETCHBalanceOwing} - {@AgentClientTotal} = 0 then
&quot;Discrepancy&quot;

&quot;Discrepancy&quot; does not appears in the report.

Any ideas anyone?
 
I suspect that

{@FETCHBalanceOwing} - {@AgentClientTotal} might not really equal 0

but rather that

{@FETCHBalanceOwing} - {@AgentClientTotal} = a very small fraction of an integer, that when rounded up then = 0.

You can check this if you take rounding off of the format for the field showing the result of {@FETCHBalanceOwing} - {@AgentClientTotal}.

In your IF statement, either use the round function (i.e. if round(field showing result of subtraction} <> 0 then 'Discrepancy'...), or use <1.

Naith
 
Your problem is not here but in these formulas perhaps{@FETCHBalanceOwing} , {@AgentClientTotal}

Also...why show us only part of the formula? (unless this is the whole formula then there may be other issues to talk about)

Show us this formula...the ones I indicated...and where they are located in the report relative to eachother...ie which sections they appear.

then pehaps we can answer your question

Jim Broadbent
 
another approach if it is the problem of not getting exactly zero for the difference tehn you could establish a tolerance....for example:

if ABS({@FETCHBalanceOwing}-{@AgentClientTotal}) <= 0.0001
then
&quot;Discrepancy&quot;

The absolute value of the difference is take since the subtraction could be negative

Jim Broadbent
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top