Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Maybe I have been looking at this code for too long.
if(Trim(QTrnType)<>'IC',QQty,-1*QQty) as UQty, |
For the above example the output of the expression looks like this
QTrnType is IC, QQty is 1 and UQty is -1
QTrnType is IN, QQty is 1 and UQty is 1
QTrnType is IT, QQty is 2 and UQty is 2
if(Trim(QTrnType)='IC',QQty,-1*QQty) as UQty, |
In the above example the opposite happens????
QTrnType is IC, QQty is 1 and UQty is 1
QTrnType is IN, QQty is 1 and UQty is -1
QTrnType is IT, QQty is 2 and UQty is -2
I would expect the output of these examples to be the opposite - to be + and visa versa???
Any ideas?
Thanks
The if statement works like this:
If( condition, expression1, expression2)
if condition is true then evaluate expression1, if condition is false then evaluate expression2
if(Trim(QTrnType)<>'IC',QQty,-1*QQty) as UQty
QTrnType is IC -> trim(QTrnType)<>'IC' is False -> multiply QQty with -1 -> result: -1
if(Trim(QTrnType)='IC',QQty,-1*QQty) as UQty
QTrnType is IC -> trim(QTrnType)='IC' is True-> take QQty -> result: 1
<> is the opposite of =, so the results are the opposites too.
The if statement works like this:
If( condition, expression1, expression2)
if condition is true then evaluate expression1, if condition is false then evaluate expression2
if(Trim(QTrnType)<>'IC',QQty,-1*QQty) as UQty
QTrnType is IC -> trim(QTrnType)<>'IC' is False -> multiply QQty with -1 -> result: -1
if(Trim(QTrnType)='IC',QQty,-1*QQty) as UQty
QTrnType is IC -> trim(QTrnType)='IC' is True-> take QQty -> result: 1
<> is the opposite of =, so the results are the opposites too.
Thank you Gysbert