Alternative construct(s) to IF THEN ELSE () function
Posted: Thu Apr 22, 2010 8:21 am
Hi,
A number of experts warn against using the IF THEN ELSE function. I would like to know a better alternative construct to a situation like this one.
shortage = (desired quantity - available quantity)/desired quantity.
It is possible that with time (during a simulation), available quantity being a stock may accumulate to level where it is more than desired quantity, resulting into shortage being negative.
To avoid shortage being a negative value, I have used the IF statement as follows:
shortage = IF THEN ELSE(desired quantity>=available quantity, (desired quantity - available quantity)/desired quantity, 0)
What alternative construct(s) can be used to achieve the same results being achieved while using the IF THEN ELSE () function?
Thanks
A number of experts warn against using the IF THEN ELSE function. I would like to know a better alternative construct to a situation like this one.
shortage = (desired quantity - available quantity)/desired quantity.
It is possible that with time (during a simulation), available quantity being a stock may accumulate to level where it is more than desired quantity, resulting into shortage being negative.
To avoid shortage being a negative value, I have used the IF statement as follows:
shortage = IF THEN ELSE(desired quantity>=available quantity, (desired quantity - available quantity)/desired quantity, 0)
What alternative construct(s) can be used to achieve the same results being achieved while using the IF THEN ELSE () function?
Thanks