Bernard Liengme said:
A1=3, A2=4, A2-A1 = 1, A2>A1 = TRUE
A1=-3, A4=-4, A2-A1=-1, A2>A1=FALSE
I know that; but I do not understand what point you are trying to make with
that information.
The OP's expression is: if(at1>av1,at1-av1,0). Your implied expression is:
if(A2>A1,A2-A1,0). So AT1 and AV1 correspond to your A2 and A1
respectively.
The OP wrote [in your terms]: "if the number in av1 [A1] is greater than
at1 [A2] it returns a negative number, rather than returning 0".
If A1=-3 and A2=-4, AV1 [A1] is indeed greater than AT1 [A2]. But
if(A2>A1,A2-A1,0) correctly results in 0, not the __negative__ number that
the OP complained about.
Perhaps you are assuming that the OP thinks (or wants) -4 > -3 since 4 >
3 -- in other words, considering only the magnitude of numbers, not their
signs. But in that case, since if(A2>A1,A2-A1,0) results in 0, I would
expect the OP to complain about getting __0__.
Moreover, if that were the OP's thinking, the example, in your terms, would
be A1=-4 and A2=-3 so that "the number in av1 [A1] is greater than at1 [A2]"
(in magnitude). But in that case, since AT1 [A2] is actually greater and
if(A2>A1,A2-A1,0) correctly results in 1, I would expect the OP to complain
about __not__ getting 0 -- or perhaps about getting a __positive__ number.
I believe if(A2>A1,A2-A1,0) always has the correct non-negative result
regardless of the signs of A1 and A2, except for the anomalies that I noted
in my two postings, namely: (a) a corner-case with precision (inconsistent
Excel heuristics); and (b) numeric-like text instead of actual numeric
values (inconsistent Excel treatment in relational and arithmetic
expressions).
If the OP were expecting a negative result when AV1 [A1] and/or AT1 [A2] is
negative, I might understand a point you could make, namely: the IF()
expression will not return negative results normally. (And of course, we
could suggest changes to correct that.)
But that is not what the OP wrote. On that other hand, you might invoke the
Greg House Law and presume that the OP misspoke ;-).
If I missed your point or misread or misinterpreted something, please
explain further. Your feedback would be appreciated in any case. Thanks.
----- original message -----