The IIF function, used in many Project formulas, is often a source of confusion. Here is the format of the IIF function:
iif(expression, value if true, value if false)
where:
expression = a test, in the form of a numeric value, a formula, field, or expression, like [FINISH]>= 20
value if true = the number value to assign to the field you are defining if the test is true
value if false = the number value to assign to the field you are defining if the test is false
Quite frequently, the false field or true field will contain another IIF expression that is evaluated to produce another value.
For instance:
We have CV1% as our field, that we renamed from a number.
The values we want to test for are:
CV1% > 0 (proves value exists)
CV1% < 100
CV1% > 100 and CV1% < 200
CV1% > 200
If we use a formula, we would have:
CV1% = IIF([CV%]<=100,1,IIF([CV%]>201,3,IIF([CV%]>101,2,0)))
The first expression evaluated is:
CV1% = IIF([CV%]<=100 If this is true, then CV1% will be assigned the value 1
If this is false, then CV1% will be assigned the value of the expression IIF([CV%]>201
If this 2nd expression (IIF([CV%]>201) is true, then CV1% will be assigned the value 3.
If this 2nd expression (IIF([CV%]>201) is false, then CV1% will be assigned the value of the expression IIF([CV%]>101)
If this 3rd expression (IIF([CV%]>101) is true, then CV1% will be assigned the value 2
If this 3rd expression (IIF([CV%]>101) is false, then CV1% will be assigned the value 0.
|