9.5 IF/IIF Conditions on Formula Terms

In some cases, a term is not included in a formula or you need to choose between two terms based on some data values. In those instances, you can use either a IF THEN ELSE condition or IIF (Immediate IF) function to specify when each term should be included. For example, if you only want to include variable vector Produce, if the corresponding data vector value for cost is greater than zero, you can enter this as follows:

    ... IF (Cost[product] > 0) THEN Produce[product] ENDIF + ...
The same term can be entered using the IIF function statement which sometimes is more readable:
    ... IIF(Cost[product] > 0, Produce[product]) + ...

When you are choosing between two terms based on a data value, you can use the ELSE statement to specify the alternative term. For example:

    InvtBal[prod, month]:
        IF (month = 1) THEN StartInvt[prod] ELSE Invt[month-1] ENDIF + ...

Or, alternatively, using the IIF function statement:

    InvtBal[prod, month]:
        IIF(month = 1, StartInvt[prod], Invt[month-1])

Back To Top | Maximal Home Page | Table of Contents | Previous Page | Next Page