Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have seen on e expression, which is like : Sum(-(Amnt>0)*Amnt)
Why we have to write like this , what is the need , since we have got Amnt already in expression.
why we have to use sum(-(Amnt>0)) extra..
Thanks...
Amnt>0 returns -1 (True) or 0 (False). Hence Sum(-(Amnt>0)) sums -(-1) (i.e. 1) for values of Amnt greater than zero. Hence the entire expression is actually equivalent to Sum(If(Amnt>0, Amnt,0)).
Amnt>0 returns -1 (True) or 0 (False). Hence Sum(-(Amnt>0)) sums -(-1) (i.e. 1) for values of Amnt greater than zero. Hence the entire expression is actually equivalent to Sum(If(Amnt>0, Amnt,0)).
Sum(-(Amnt>0)*Amnt)
If Amnt>0 is true then the expression become: Sum(-(-1)*Amnt) that is Sum(Amnt)
If amnt>0 is false then Sum(-(0)*Amnt) that is 0
We are summing only positive values for amount
This will give you a value of decimal zero when you have a negative figure in Amnt, thus only summing up positive values.
The expression (Amnt>0) will either return True (-1) or False (0)
Hope this helps to clear up your question.
Best regards
Stefan
Hi tresesco,
Thanks for your reply, that is ok but.. why we have to use this Sum(-(Amnt>0)), instaed directly we can use
Sum(Amnt) rt..?
If you have negative values in Amnt, they would not be summed. Sum(Amnt) - sums all irrespective of if Amnt is positive or negative. Hope this helps.