Try again, using the same logic/format I used in my first thread (you only need two IIFs to do it this way)
Code:
MyColor: IIF([Degree of Impact]>4,"Red",IIF([Degree of Impact]>=3,"Yellow","Green"))
It is important to understand a few things about IIF statements:
1. The IIF statement has three arguments:
IIF(condition, what to return if condition is true, what to return if condition is false)
2. If you have a nested IIF statement, working from left to right, once a condition is met, it will stop there and not look at the rest.
So, if we follow the logic of my statement above, here is what it is doing:
- First checks to see if "Degree of Impact" is greater than 4, and if it is, it will return "Red".
- If it is not, it looks at the second condition to see if it is greater than or equal to 3, and if it is it will return "Yellow"
(there is no need to check to see if it is also less than 4 here, because if it is greater than 4, the first condition would have picked it up).
- if it is not greater than or equal to 3, we know that is must be less than 3, so we don't even need to check to see if it less than 3 (because we know by process of elimination).
So we can simply tell it to return "Green" if neither of the first two conditions are true.
As long as you always order you conditions to work in increasing order (or decreasing order), you can use this type of logic and not have to explicitly check to see if it is between two values (unless you have gaps that would want ignored).
Make sense?